Skip to content

Commit

Permalink
Merge pull request #3 from lnty/padding-dev
Browse files Browse the repository at this point in the history
Add ability to specify padding
  • Loading branch information
Sudoxe authored May 10, 2019
2 parents d341b19 + ccee644 commit 1e458fc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.main.py.swp
test.py
24 changes: 18 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,42 @@
try:
from pyfiglet import figlet_format
except ImportError:
print('Error, module pyfiglet is required. Run: pip3 install pyfiglet')
print('Error, module pyfiglet is required. Run: sudo pip3 install pyfiglet')

# VARIABLES
padding = [0, 0, 0, 0]
font_name = '3x5'
padding = [1, 0, 0, 3]
font_name = '3x5'
custom_char_replace = {'#': '\u2588'}
time_format = '%H:%M:%S'
time_format = '%H:%M:%S'
update_frequency = 1

while True:
# Clear the screen to make the clock appear 'in-place'
os.system('clear')

# Convert the current time to the defined format
time_string = datetime.datetime.now().strftime(time_format)

# Turn the string into a figlet ASCII art string
figlet_string = figlet_format(time_string, font=font_name)

# Replace any characters
for char in custom_char_replace:
figlet_string = figlet_string.replace(char, custom_char_replace[char])

# Apply padding
# Top padding
for i in range(padding[0]):
print()

# Right padding (useless until text alignment added)
# Bottom padding (pretty much useless as well)
# Left padding
for i in range(padding[3]):
figlet_string.replace('\n', '\n ')

# Print the string
print(figlet_string)

# Sleep
time.sleep(1)
time.sleep(update_frequency)

0 comments on commit 1e458fc

Please sign in to comment.