Skip to content

Add support for justify #6

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ The variables at the start of the script can all be changed to modify the look a

| Variable | Default | Description | Useful Link(s) |
|--------------------- |-------------------------- |-------------------------------------------------------------------------------- |------------------------------------------------------ |
| font_name | ``` '3x5' ``` | Changes the Figlet font which is rendered | [Figlet Font DB](http://www.figlet.org/fontdb.cgi) |
| font_name | ``` '3x5' ``` | Changes the Figlet font which is rendered | [Figlet Font DB](http://www.figlet.org/fontdb.cgi) |
| padding | ``` [0, 0, 0, 0] ``` | Applies padding to the top/right/bottom/left of the text | |
| width | terminal width | Defines the width for ```justify``` to work. By default is equal to terminal's width | |
| justify | ``` 'center' ``` | Justify the output ('auto', 'left', 'center', 'right') | |
| custom_char_replace | ``` {'#': '\u2588'} ``` | Used to replace the character(s) in the key with the character(s) in the value | [Unicode Character Table](https://unicode-table.com) |
| time_format | ``` '%H:%M:%S' ``` | Set the format of the time to be displayed | [Time Formatting Parameters](http://strftime.org/) |

Expand Down
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

# VARIABLES
padding = [1, 0, 0, 3]
width = os.get_terminal_size().columns
justify = 'center'
font_name = '3x5'
custom_char_replace = {'#': '\u2588'}
time_format = '%H:%M:%S'
Expand All @@ -22,7 +24,7 @@
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)
figlet_string = figlet_format(time_string, font=font_name, width=width, justify=justify)

# Replace any characters
for char in custom_char_replace:
Expand Down