I'm making a Treasure Island type game using tkinter and trying to increase the font size while having a sort of typerwriter effect that prints out the letters one by one. I've gottten them to work by themselves but when I put them both together I get the error "TypeError: can only concatenate str (not "int") to str" in line 39.
code:
import tkinter
window = tkinter.Tk()
window.title("Treasure Island")
window.attributes('-fullscreen', True)
logo = tkinter.Label(window, text='''
| | | |
_________|________________.=""_;=.______________|_____________________|_______
| | ,-"_,="" `"=.| |
|___________________|__"=._o`"-._ `"=.______________|___________________
| `"=._o`"=._ _`"=._ |
_________|_____________________:=._o "=._."_.-="'"=.__________________|_______
| | __.--" , ; `"=._o." ,-"""-._ ". |
|___________________|_._" ,. .` ` `` , `"-._"-._ ". '__|___________________
| |o`"=._` , "` `; .". , "-._"-._; ; |
_________|___________| ;`-.o`"=._; ." ` '`."\` . "-._ /_______________|_______
| | |o; `"-.o`"=._`` '` " ,__.--o; |
|___________________|_| ; (#) `-.o `"=.`_.--"_o.-; ;___|___________________
____/______/______/___|o;._ " `".o|o_.--" ;o;____/______/______/____
/______/______/______/_"=._o--._ ; | ; ; ;/______/______/______/_
____/______/______/______/__"=._o--._ ;o|o; _._;o;____/______/______/____
/______/______/______/______/____"=._o._; | ;_.--"o.--"_/______/______/______/_
____/______/______/______/______/_____"=.o|o_.--""___/______/______/______/____
/______/______/______/______/______/______/______/______/______/______/_____ /
''')
logo.pack()
logo.config(font=('length', 15))
line1 = tkinter.Label(window, text="Welcome to Treasure Island,\n"
"Your goal is to find the buried Treasure!")
line1.config(font=('length', 15))
label1 = tkinter.StringVar()
a = tkinter.Label(textvariable=label1)
a.pack()
for i in line1:
a=label1.get()
label1.set(a i)
window.after(50)
window.update()
space = tkinter.Label(window, text=" \n \n ")
space.pack()
CodePudding user response:
To get text in your line1
label character by character and show it in sequence, maybe this is what you need
for i in line1.cget("text"):
a=label1.get()
label1.set(a i)
window.after(50)
window.update()