pythonpysimpleguiascii-art

PySimpleGUI ASCII Art won't display properly


I am currently making a project and utilizing PySimpleGUI for my GUI. I am wanting to display ASCII ART however it is not properly displaying. To my reasoning is due to the characters being properly displayed however the spaces get condensed down when transferred over and displayed. Thus causing it to be malformed.

Image of results: enter image description here Code:

def EnumResults():

sg.theme('DarkPurple6')


ART = """ 


    ..  . .....   . .....   ......    .....     .....     ....   . .....   . ....   
    ..   .......   .....     .....     ....     .....   . .....   .......   ..... . 
    ..../#################################################################(,  ....
    . ..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@, ...
    ..  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/. . 
    ..  @@@@@@@,.  ........  ..... ..  ..... .. ...... ......... .......&@@@@@@/. . 
    ..@@@@@@@,.....  . .... .  ...... .  .....  .  .....  . .....   . &@@@@@@/....
    . ..@@@@@@@,.... .  .....  .  .....  . .....   . .....   ......    .&@@@@@@/ ...
    ..  @@@@@@@.  . ......  ...... .  .....  .  .....  .  .....  . .....&@@@@@@/. . 
    ... @@@@@@@..  .....  .  .....  .  .....  . .....   . .....   ......&@@@@@@/.   
    ..@@@@@@@,.....  ...... .  ...... .  .....  .  .....  . ......  . &@@@@@@/....
    .  .@@@@@@@. .. .....  ........  ...... .  ...... .  .....  .  .....&@@@@@@/..  
    ..  @@@@@@@.  . ......  ...... .  .....  .  .....  .  .....  . .....&@@@@@@/. . 
    ...@@@@@@@,....  .  .....  . ......   ..... .   ..... .  .....  .  &@@@@@@/ ...
    ..@@@@@@@,.....  ...... .  ...... .  .....  .  .....  . ......  . &@@@@@@/....
    .. .@@@@@@@. .  .....  . ......    .... .   ..... .  .....  .  .....&@@@@@@/..  
    ..  @@@@@@@,  . ......   ..... .  .....  .  .....  .  .....  . .....&@@@@@@/. . 
    ..@@@@@@@,....  .  .....    ......   ..... .   ..... .  .....  .  &@@@@@@/ ...
    ..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/....
    .. .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/..  
    ..  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.  #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/. . 
    ..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/ ...
    ..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/....
    ..  .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*...  
    ..  . ......  . .... .  ...... .(@@@@@@@@@@@@@@..  .  .....  . ......  . .... . 
    ....     .....   . .....   ...(@@@@@@@@@@@@@@  ..... .  .....     .....    ...
    .....  . ......   ..... .   ..(@@@@@@@@@@@@@@  .....  . ......  . ......  ....
    ..  . .....   . .....   .%@@@@@@@@@@@@@@@@@@@@@@@@@@@@....     .....     .....  
    ..  . ......  . .... .  ...... .   ....  .  .....  .  .....  . ......  ...... . 
    ....   . .....   . .....   .......   ..... .   ..... .  .....  .  .....    ...
        


    """

layout = [
    
        
        [sg.Text("Coyote", size=(40, 1), font=('Any 15'))],
        [sg.Image(source='images/desktop.png', size=(300,100))],
        [sg.Text(ART, auto_size_text=True )],
        [sg.Text("Results from enumeration")],
        [sg.Output(size=(100,30))],
        [sg.Button("Display", key="-ESEND-", bind_return_key=True)],
        [sg.Button("Exit", button_color=('white', 'firebrick3'), key='Exit') ]
        
        
        ]
window = sg.Window("Results Window", layout, icon='images/Coyote.ico', no_titlebar=True, grab_anywhere=True, element_justification='c', alpha_channel=.9)
choice = None
while True:
    event, values = window.read()
    if event == "-ESEND-":
        
        nmr = ps.read_csv('nmapdump.csv', sep = ';', header = 0)
        print( "\n", nmr[['protocol', 'port', 'name', 'state', 'reason']])
        for i in nmr.index:
            print(nmr['port'][i])
        
    if event == "Exit" or event == sg.WIN_CLOSED:
        break

window.close()

Any help is greatly appreciated.


Solution

  • I mentioned in the comments using a fix-width font, just as the other responders that commented before I did. I wanted to show the result of using Courier.

    There are 2 PySimpleGUI "Demo Programs" that may be of interest. One is Demo_pyfiglet. The other is Demo_OpenCV_Webcam_ASCII. Both can be found in the PySimpleGUI Repo.

    They both simply use the courier font as it's likely on every platform. It's on Android for example when using pydroid3 in addition to the usual Windows, Mac and Linux.

    enter image description here enter image description here