python - Displaying ASCII-art in TKinter -


i trying develop offline version of candy box (solely personal use only) using tkinter , ascii art won't display on tkinter canvas.

this way i'd displayed:

"""         .---.        |   '.|  __        | ___.--'  )      _.-'_` _%%%_/   .-'%%% a: %%%       %%  l   %%_       _%\'-' |  /-.__    .-' / )--' #/     '\   /'  /  /---'(    :   \  /   |  /( /|##|  \     | /   ||# | / | /|   \    \ |   ||##| \/ |   |   _| |   ||: | o  |#|   |  / | |   ||  /  |:/  /   |/ |   ||  | o   /  /    / |   \|  |  |. /    /  \  /|##| o  |.|    /   \/ \::|/\_ /  ---'|   """) 

and way displayed (i've attempted changing font used in idle (courier, 10), because seemed display correctly, didn't seem help.

using following code, ended looking like:

self.merchantshow = tk.label(self, font=self.fontused, text= """         .---.        |   '.|  __        | ___.--'  )      _.-'_` _%%%_/   .-'%%% a: %%%       %%  l   %%_       _%\'-' |  /-.__    .-' / )--' #/     '\   /'  /  /---'(    :   \  /   |  /( /|##|  \     | /   ||# | / | /|   \    \ |   ||##| \/ |   |   _| |   ||: | o  |#|   |  / | |   ||  /  |:/  /   |/ |   ||  | o   /  /    / |   \|  |  |. /    /  \  /|##| o  |.|    /   \/ \::|/\_ /  ---'|   """)             self.merchantshow.grid(row=4, column=0, stick="w") 

failed art

can please me solve , explain why happening? i'm assuming has font, i'm sure there's got easier way going through fonts.

  1. align text left (center default)
  2. backslash @ line end have special meaning in python: wraps long lines. use raw strings


from tkinter import *  text = r"""         .---.        |   '.|  __        | ___.--'  )      _.-'_` _%%%_/   .-'%%% a: %%%       %%  l   %%_       _%\'-' |  /-.__    .-' / )--' #/     '\   /'  /  /---'(    :   \  /   |  /( /|##|  \     | /   ||# | / | /|   \    \ |   ||##| \/ |   |   _| |   ||: | o  |#|   |  / | |   ||  /  |:/  /   |/ |   ||  | o   /  /    / |   \|  |  |. /    /  \  /|##| o  |.|    /   \/ \::|/\_ /  ---'|   """  root = tk() label(root, justify=left, text=text).pack() root.mainloop() 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -