ASCII art banner for your Python script

ASCII art banner for your Python script

ยท

3 min read

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.

Text converters

Image converters

ย