Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to specify padding #3

Merged
merged 8 commits into from
May 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)