Creating ASCII art
I experimented with ways to create ASCII art to implement as a banner for my Python terminal app. There are several free online ASCII art creators (links included below). I first tested out those. However, the characters would be skewed and messed up whenever I copied/pasted the results into my Pycharm IDE code file. I could not figure out how to correct this.
Sometime later, I discovered the Figlet plugin! ๐ฏ (Yes. I should have checked the JetBrains plugin marketplace first . ๐ค ).
Figlet plugin
This Figlet plugin for the Pycharm IDE solved my problem. It works like a charm. I've created the GIF below to demonstrate how to install it and how it works. This should get you going.
Example implementation
The code
Below is a script showing how you can implement the ASCII art banner. There are different ways to do this, depending on your needs. I am keeping things simple here.
from time import sleep
# Define some developer details
__author__ = 'Joe Plumber'
__date__ = '2030-09-20'
__details__ = 'This app does cool stuff'
# Define some colors and styles as constants
PURPLE = '\033[95m'
CYAN = '\033[96m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
UNDERLINE = '\033[4m'
ORANGE = '\033[33m'
GREY = '\033[90m'
RESET = '\033[0;0m' # return terminal to original color scheme
# Set the time interval (in seconds) between printing each line
interval = 0.3
def print_banner():
'''Prints the banner. Character color is set to cyan. Each line is printed after 0.3 seconds.'''
print(f'{CYAN}'
'โโโโโโ โโโโโโโโ โโโโโโโโโโโโโ โโโโโโ โโโโโโโ โโโโโโโโโ'); sleep(interval)
print('โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโ'); sleep(interval)
print('โโโโโโโโโโโโโโโโโโโ โโโโโโ โโโโโโโโโโโโโโโโ โโโ '); sleep(interval)
print('โโโโโโโโโโโโโโโโโโโ โโโโโโ โโโโโโโโโโโโโโโโ โโโ '); sleep(interval)
print('โโโ โโโโโโโโโโโโโโโโโโโโโโโโโ โโโ โโโโโโ โโโ โโโ '); sleep(interval)
print('โโโ โโโโโโโโโโโ โโโโโโโโโโโโโ โโโ โโโโโโ โโโ โโโ '); sleep(interval)
print(f'{RESET}')
def print_dev_details():
'''Prints information about the application. Different colors and styles are used.'''
print(f'{PURPLE}Author:{UNDERLINE}{__author__}{RESET}')
sleep(interval)
print(f'{YELLOW}Date: {__date__}')
sleep(interval)
print(f'{BLUE}Details: {__details__}')
print(f'{RESET}')
def menu():
'''Returns a multi-line text string representing the menu.'''
return ("""
ENTER 1 - 3 TO SELECT OPTIONS
1. DO STUFF Do something
2. DO OTHER STUFF Do something else
3. REPORT Generate a report
4. EXIT Exit to the terminal
""")
# Display the banner, developer details and menu
print_banner()
print_dev_details()
print(menu())
Demo
Below is a GIF demonstrating the results of the above code.
Copy and paste the code into a file. In my case, I named the file demo_art.py. Run it from the terminal:
$ python3 demo_art.py
Results:
Have fun!
References:
Here are lists of the ASCII converters I tried out.