How to fix Tkinter label not appearing? - python

I'm making a game in Tkinter. A dynamic clicker game where you have to buy what you 'click'. I've been trying to get an inventory screen going but I've run into a problem I cant understand. When the player opens the 'Inventory' screen by clicking a button, a window appears with all the fruits they have (eg. Apples: 654 (A testing number)). But for some reason, nothing appears. At all. There is no error and no label. Why is this?
Code:
from tkinter import *
money = 0
currentfruit = "Apple"
numOfApples = 654
def clicked():
global money
global currentfruit
if currentfruit == "Apple":
money = money + 1
moneystringvar.set("You have $" + str(money))
if money < 10:
moneylabel.place(x="327", y="0")
if money < 100 and money > 9:
moneylabel.place(x="320", y="0")
if money < 1000 and money > 99:
moneylabel.place(x="315", y="0")
def inventoryOnClose():
root.deiconify()
inventorywindow.destroy()
def marketOnClose():
root.deiconify()
marketwindow.destroy()
def upgradesOnClose():
root.deiconify()
upgradeswindow.destroy()
def inventory():
global inventorywindow
global numOfApples
root.withdraw()
inventorywindow = Tk()
inventorywindow.title("Fruit Clicker - Inventory")
inventorywindow.geometry("400x350+300+100")
inventorywindow.protocol("WM_DELETE_WINDOW", inventoryOnClose)
applesinventory = StringVar()
applesinventory.set("Apples: " + str(numOfApples))
applesinvlabel = Label(inventorywindow, textvariable=applesinventory)
applesinvlabel.place(x="0", y="0")
inventorywindow.mainloop()
def market():
global marketwindow
root.withdraw()
marketwindow = Tk()
marketwindow.title("Fruit Clicker - Market")
marketwindow.geometry("400x350+300+100")
marketwindow.protocol("WM_DELETE_WINDOW", marketOnClose)
marketwindow.mainloop()
def upgrades():
global upgradeswindow
root.withdraw()
upgradeswindow = Tk()
upgradeswindow.title("Fruit Clicker - Upgrades")
upgradeswindow.geometry("400x350+300+100")
upgradeswindow.protocol("WM_DELETE_WINDOW", upgradesOnClose)
upgradeswindow.mainloop()
root = Tk()
root.title("Fruit Clicker")
root.geometry("400x350+300+100")
inventorybutton = Button(root, text="Inventory", fg="White", bg="Black", width="6", command=inventory)
inventorybutton.grid(column="0", row="0")
marketbutton = Button(root, text="Market", fg="White", bg="Black", width="6", command=market)
marketbutton.grid(column="0", row="1")
upgradesbutton = Button(root, text="Upgrades", fg="White", bg="Black", width="6", command=upgrades)
upgradesbutton.grid(column="0", row="2")
leftfruitbutton = Button(root, text="<")
leftfruitbutton.place(x="100", y="285")
currentfruitstringvar = StringVar()
if currentfruit == "Apple":
currentfruitstringvar.set("Apple x" + str(numOfApples))
currentfruitlabel = Label(root, textvariable=currentfruitstringvar, fg="Black")
if numOfApples < 10:
currentfruitlabel.place(x="180", y="290")
if numOfApples < 100 and numOfApples > 9:
currentfruitlabel.place(x="175", y="290")
if numOfApples < 1000 and numOfApples > 99:
currentfruitlabel.place(x="170", y="290")
rightfruitbutton = Button(root, text=">")
rightfruitbutton.place(x="287", y="285")
moneystringvar = StringVar()
moneystringvar.set("You have $" + str(money))
moneylabel = Label(root, textvariable=moneystringvar)
if money < 10:
moneylabel.place(x="327", y="0")
if money < 100 and money > 9:
moneylabel.place(x="320", y="0")
if money < 1000 and money > 99:
moneylabel.place(x="315", y="0")
clickerphoto = PhotoImage(file = "apple.png")
clickerbutton = Button(root, text="Clicker Button", image=clickerphoto, fg="Black", command=clicked)
clickerbutton.place(x="100", y="75")
root.mainloop()
I'm not sure if you need apple.png but if you do, here is a link to my GitHub Repo: https://github.com/SeaPuppy2006/FruitClicker
Thanks!

#jizhihaoSAMA answered in the comments.
Instead of upgradeswindow = Tk() it should be upgradeswindow = Toplevel() same for all children of the original Tk() window.

Related

Tkinter Displaying Wrong Thing at Incorrect Time

I am trying to create a clicker game, and all the basic fundamentals are in; there's a button, you can click it, there's an upgrade, you can infinitely buy it while the price goes up 15%. Now, all of this is fine, but I want to implement a "prestige" for the upgrade; if you buy the upgrade 10 times, you will have to pay a price 5x the cost, but after that the upgrade will give you more rewards. I decided to put a counter in, and whenever you buy the upgrade, it goes up. Now, here is my problem. I put an if statement for when the counter reaches 10 (all of the data for that upgrade is stored in its own dictionary), it will change the text and cost. This does not work at all. Instead, it keeps the same text, and after buying it 1 - 3 more times, it will change the reward given, but nothing else.
Here is my code:
from tkinter import *
from threading import Timer
window = Tk()
window.minsize(1200, 500)
window.title("Clicker Game")
# general setup
default_font = ("Calibri", 15, "normal")
clicks = 0
click_power = 1
# upgrade variables
upgrade1_stats = {
"cost": 15,
"can buy": False,
"times bought": 0,
"click power given": 1,
"prestige": False,
}
# functions
def check_clicks():
global clicks, upgrade1_stats
if clicks >= 10:
upgrade1.place(x=200, y=50)
if clicks >= upgrade1_stats["cost"]:
upgrade1_stats["can buy"] = True
else:
upgrade1_stats["can buy"] = False
def get_upgrade1():
global clicks, upgrade1_stats, click_power
if upgrade1_stats["times bought"] == 10 and upgrade1_stats["can buy"]:
upgrade1_stats["cost"] = int(upgrade1_stats["cost"] * 5)
update_stats()
upgrade1_stats["prestige"] = False
upgrade1_stats["click power given"] += 1
upgrade1_stats["times bought"] += 1
if upgrade1_stats["can buy"]:
clicks -= upgrade1_stats["cost"]
click_power += upgrade1_stats["click power given"]
upgrade1_stats["cost"] = int(upgrade1_stats["cost"] * 1.15)
upgrade1_stats["times bought"] += 1
update_stats()
else:
not_enough_clicks()
check_clicks()
if upgrade1_stats["prestige"]:
upgrade1.config(text=f"MAX UPGRADES BOUGHT\nPRESTIGE COST: {upgrade1_stats['cost']}")
else:
upgrade1.config(text=f"+{upgrade1_stats['click power given']} Click Power\nCost: {upgrade1_stats['cost']}")
def not_enough_clicks():
new_label = Label(text="NOT ENOUGH CLICKS", font=("Calibri", 80, "bold"))
new_label.place(x=125, y=180)
t = Timer(1, new_label.destroy)
t.start()
def increase_score(*args):
global clicks
if len(args) > 0:
update_amount = args[0]
else:
update_amount = click_power
clicks += update_amount
update_stats()
check_clicks()
def update_stats(**kwargs):
global clicks, click_power
click_display.config(text=f"{clicks} Clicks")
if click_power == 1:
click_power_display.config(text=f"{click_power} Click per Button Click")
else:
click_power_display.config(text=f"{click_power} Clicks per Button Click")
# title text
title_label = Label(text="Clicker Game", font=("Calibri", 30, "bold"))
title_label.grid(column=1, columnspan=2, row=1)
window.grid_columnconfigure(2, weight=1)
window.grid_rowconfigure(1, weight=1)
# click display
click_display = Label(text=f"{clicks} Clicks", font=default_font)
click_display.grid(column=2, row=2)
window.grid_rowconfigure(2, weight=0, pad=70)
# button to click
clicker = Button(text="Click Me", command=increase_score, height=3, width=10, bg="red")
clicker.grid(column=2, row=3)
window.grid_rowconfigure(3, pad=200)
# click power display
click_power_display = Label(text=f"{click_power} Click per Button Click", font=default_font)
click_power_display.place(x=495, y=150)
# upgrades
upgrade1 = Button(text=f"+1 Click Power\nCost: {upgrade1_stats['cost']}", command=get_upgrade1)
window.mainloop()
The expectation is that once buying the upgrade 10 times, it would change the text to "MAX UPGRADES REACHED. PRESTIGE COST: (prestige cost here)". This is not at all what is happening, and I am very confused why. Any and all help would be greatly appreciated by me.
EDIT
With the help of #Alexander, I did update my code to this:
from tkinter import *
from threading import Timer
window = Tk()
window.minsize(1200, 500)
window.title("Clicker Game")
# general setup
default_font = ("Calibri", 15, "normal")
clicks = 0
click_power = 1
# upgrade variables
upgrade1_stats = {
"cost": 15,
"can buy": False,
"times bought": 0,
"click power given": 1,
"prestige": False,
}
# functions
def check_clicks():
global clicks, upgrade1_stats
if clicks >= 10:
upgrade1.place(x=200, y=50)
if clicks >= upgrade1_stats["cost"]:
upgrade1_stats["can buy"] = True
else:
upgrade1_stats["can buy"] = False
def get_upgrade1():
global clicks, upgrade1_stats, click_power
if upgrade1_stats["times bought"] == 10 and upgrade1_stats["can buy"]:
upgrade1_stats["cost"] = int(upgrade1_stats["cost"] * 5)
update_stats()
upgrade1_stats["prestige"] = True
upgrade1_stats["click power given"] += 1
upgrade1_stats["times bought"] += 1
elif upgrade1_stats["can buy"] and upgrade1_stats["times bought"] != 10:
clicks -= upgrade1_stats["cost"]
click_power += upgrade1_stats["click power given"]
upgrade1_stats["cost"] = int(upgrade1_stats["cost"] * 1.15)
upgrade1_stats["times bought"] += 1
upgrade1_stats["prestige"] = False
update_stats()
else:
not_enough_clicks()
check_clicks()
if upgrade1_stats["prestige"]:
upgrade1.config(text=f"MAX UPGRADES BOUGHT\nPRESTIGE COST: {upgrade1_stats['cost']}")
else:
upgrade1.config(text=f"+{upgrade1_stats['click power given']} Click Power\nCost: {upgrade1_stats['cost']}")
def not_enough_clicks():
new_label = Label(text="NOT ENOUGH CLICKS", font=("Calibri", 80, "bold"))
new_label.place(x=125, y=180)
t = Timer(1, new_label.destroy)
t.start()
def increase_score(*args):
global clicks
if len(args) > 0:
update_amount = args[0]
else:
update_amount = click_power
clicks += update_amount
update_stats()
check_clicks()
def update_stats(**kwargs):
global clicks, click_power
click_display.config(text=f"{clicks} Clicks")
if click_power == 1:
click_power_display.config(text=f"{click_power} Click per Button Click")
else:
click_power_display.config(text=f"{click_power} Clicks per Button Click")
# title text
title_label = Label(text="Clicker Game", font=("Calibri", 30, "bold"))
title_label.grid(column=1, columnspan=2, row=1)
window.grid_columnconfigure(2, weight=1)
window.grid_rowconfigure(1, weight=1)
# click display
click_display = Label(text=f"{clicks} Clicks", font=default_font)
click_display.grid(column=2, row=2)
window.grid_rowconfigure(2, weight=0, pad=70)
# button to click
clicker = Button(text="Click Me", command=increase_score, height=3, width=10, bg="red")
clicker.grid(column=2, row=3)
window.grid_rowconfigure(3, pad=200)
# click power display
click_power_display = Label(text=f"{click_power} Click per Button Click", font=default_font)
click_power_display.place(x=495, y=150)
# upgrades
upgrade1 = Button(text=f"+1 Click Power\nCost: {upgrade1_stats['cost']}", command=get_upgrade1)
window.mainloop()
Now, there is still another problem:
The prestige only shows up after "buying" the upgrade 2 or 3 times after you actually bought it 10 times. I want it to show up after EXACTLY 10 times. Could anybody help me with this?
The reason it takes more than 10 clicks for it to appear is because you do not increment the upgrade1_stats["times bought"] until after you have already checked how many times user has previously clicked the bonus. So it takes exactly 11 times.
The solution would be to increment the times bought before checking if it has been bought 10 times, or alternatively you could start the times bought counter at 1 instead of 0.
upgrade1_stats["times bought"] += 1
I would recommend moving the above line and making a few other alterations to reduce some unnecessary code and improve readability. See inline notes in example below.
from tkinter import *
from threading import Timer
window = Tk()
window.minsize(1200, 500)
window.title("Clicker Game")
# general setup
default_font = ("Calibri", 15, "normal")
clicks = 0
click_power = 1
# upgrade variables
upgrade1_stats = {
"cost": 15,
"times bought": 0,
"click power given": 1
}
def get_upgrade1():
global clicks, click_power
if clicks < upgrade1_stats["cost"]: # if there is not enough clicks
return not_enough_clicks() # exit the function early
upgrade1_stats["times bought"] += 1 # increase times bought before check
if upgrade1_stats["times bought"] == 10:
upgrade1_stats["cost"] *= 5 # simplified multiplication
upgrade1_stats["click power given"] += 1
upgrade1.config(text=f"+{upgrade1_stats['click power given']} Click Power\nCost: {upgrade1_stats['cost']}")
else:
clicks -= upgrade1_stats["cost"]
click_power += upgrade1_stats["click power given"]
upgrade1_stats["cost"] = int(upgrade1_stats["cost"] * 1.15)
upgrade1.config(text=f"MAX UPGRADES BOUGHT\nPRESTIGE COST: {upgrade1_stats['cost']}")
update_stats()
def not_enough_clicks():
new_label = Label(text="NOT ENOUGH CLICKS", font=("Calibri", 80, "bold"))
new_label.place(x=125, y=180)
t = Timer(1, new_label.destroy)
t.start()
def increase_score(*_):
global clicks
clicks += click_power
if clicks >= 10:
upgrade1.place(x=200, y=50)
update_stats()
def update_stats(**_):
verb = "Click" if click_power == 1 else "Clicks"
click_display.config(text=f"{clicks} {verb}")
click_power_display.config(text=f"{click_power} {verb} per Button Click")
# title text
title_label = Label(text="Clicker Game", font=("Calibri", 30, "bold"))
title_label.grid(column=1, columnspan=2, row=1)
window.grid_columnconfigure(2, weight=1)
window.grid_rowconfigure(1, weight=1)
# click display
click_display = Label(text=f"{clicks} Clicks", font=default_font)
click_display.grid(column=2, row=2)
window.grid_rowconfigure(2, weight=0, pad=70)
# button to click
clicker = Button(text="Click Me", command=increase_score, height=3, width=10, bg="red")
clicker.grid(column=2, row=3)
window.grid_rowconfigure(3, pad=200)
# click power display
click_power_display = Label(text=f"{click_power} Click per Button Click", font=default_font)
click_power_display.place(x=495, y=150)
# upgrades
upgrade1 = Button(text=f"+1 Click Power\nCost: {upgrade1_stats['cost']}", command=get_upgrade1)
window.mainloop()

Updating Tkinter text with label

I'm trying to make a GUI version of a drinking game, which involves throwing dice. I 'throw the dice' virtually, but want to display the outcome on the screen. I thought using Label() would be most useful, but i'm having trouble updating that text (the throw_text variable) when a new dice throw is done.
Instead of the text updating on the screen, a new text appears below the previous one with the new throw.
I don't want a cascading stream of text, but just one singular text that updates at the dice being thrown i.e. when the 'Roll!' button is pressed.
I've seen people do it using the Stringvar(), however i must be doing it wrong as it does not have an effect on the appearance.
from tkinter import *
dim = [900, 600]
root = Tk()
root.geometry(f"{dim[0]}x{dim[1]}")
root.title("Mex")
root.iconbitmap("dice.ico")
lbl = Label(root, font=("Times", 200))
num = ['\u2680', '\u2681', '\u2682', '\u2683', '\u2684', '\u2685']
d1 = None
d2 = None
throw_txt = StringVar()
def roll_dice():
global d1, d2
d1 = random.choice(num)
d2 = random.choice(num)
lbl.config(text=f"{d1}{d2}")
lbl.pack()
lbl.place(x=dim[0] / 3.8, y=50)
print("Throw:", check_throw(convert_symbol()))
throw_txt = str(check_throw(convert_symbol()))
txt = Label(root, text=throw_txt)
txt.pack(side=TOP)
def convert_symbol():
d1_num = None
d2_num = None
for n in num:
if n == d1:
d1_num = num.index(n) + 1
if n == d2:
d2_num = num.index(n) + 1
if d2_num > d1_num:
throw = f"{d2_num}{d1_num}"
else:
throw = f"{d1_num}{d2_num}"
return throw
def check_throw(t):
num_t = int(t)
if num_t == 21:
return "Mex"
elif num_t % 11 == 0:
return f"Koning: {int(num_t / 11 * 100)}"
elif num_t % 31 == 0:
return "Slok uitdelen"
else:
return str(num_t)
roll_btn = Button(root, text="Roll!", width=10, command=roll_dice)
roll_btn.config(font=("Bahnschrift", 20))
roll_btn.pack()
roll_btn.place(x=dim[0] / 2.5, y=25)
roll_btn = Button(root, text="Convert", width=10, command=convert_symbol)
roll_btn.config(font=("Bahnschrift", 20))
roll_btn.pack()
roll_btn.place(x=dim[0] / 2.5, y=500)
root.mainloop()
You could use the configure attribute instead of storing the text of the Label widget into a separate variable.
Take a quick look at this code:
from tkinter import *
root = Tk()
root.title("my game")
def change_text():
mylabel.configure(text="You just hit the button!")
mylabel = Label(root, text="Hit the button pls")
mylabel.grid(column=0, row=1, sticky='w')
mybutton = Button(root, text="Click me", command=change_text)
mybutton.grid(column=0, row=2, sticky='w')
root.mainloop()

Jumping between functions in tkinter

so I am working on this school project and I need to be able to run the random number generator then if it is 1 go to the headspinner module but if it is 2 go to the tailspinner module. After that the code should add up the score and print it to the user.
Any advice on how to jump from one function to another in my code would be much appreciated thank you.
from tkinter import * # access tkinter library
import random # get random number generator
money = 100
#create coin flip module
def coinFlip():
flip = random.randint(1, 2)
if flip == 1:
headspinner()
else:
tailspinner()
#create headspinner module
def headspinner():
global money
head = random.randint(1, 2)
if head == 1:
money = money + 30
else:
money = money - 25
#create tailspinner module
def tailspinner():
global money
tail = random.randint(1, 4)
if tail == 1:
money = money + 2
elif tail == 2:
money = money + 5
elif tail == 3:
money = money + 10
else:
money = money + 15
#gains or losses module
def upordown():
global money
if money > 100:
screen.itemconfig(message, text = f"Congratulations, you won ${(money - 100):.2f}", font = ("Calibri", "18"))
else:
screen.itemconfig(message, text = f"Congratulations, you won ${(100 - money):.2f}", font = ("Calibri", "18"))
#create pop up box
root = Tk()
#creating canvas
screen = Canvas (root, height = 600, width = 800, bg = "lightgreen")
screen.pack()
#flip button
go = Button(root, text = "Flip", cursor = "hand2", command = coinFlip)
goButton = screen.create_window(400, 530, window = go)
#cerate title
title = screen.create_text(400, 100, text = "Welcome to Flip and Spin", font = ("Calibri", "35"))
#text for instructions
text1 = Label(root, text = "Welcome to the Flip and Spin game! \nThis game includes a quick fate of what you could encounter. \nIt starts off with a fast flip of a coin followed by a dizzying spin of a spinner. \nCome and play to decide if you will lose money, \nmake your money back, or win some easy money!", font = ("Calibri", "20"), justify = CENTER, bg = "light green")
text1label = screen.create_window(400, 300, window = text1,)
#text for final results
message = screen.create_text(400, 400, text = "Results", font = ("Calibri", "18"))
#close canvas
mainloop()
You are already switching from function to function in def coinFlip.
You just need to put everything together.
Here's a simple example to get you started:
from tkinter import Tk, Button, Label, X, LEFT, RIGHT
import random
money = 100
#create coin flip module
def coin_flip():
flip = random.randint(1, 2)
if flip == 1:
headspinner()
else:
tailspinner()
#create headspinner module
def headspinner():
global money
head = random.randint(1, 2)
if head == 1:
money = money + 30
else:
money = money - 25
text.config(text=f"Headspinner: {money}", bg="#aaafff")
#create tailspinner module
def tailspinner():
global money
tail = random.randint(1, 4)
if tail == 1:
money = money + 2
elif tail == 2:
money = money + 5
elif tail == 3:
money = money + 10
else:
money = money + 15
text.config(text=f"Tailspinner: {money}", bg="#ffaaaa")
def show_result():
global money
text.config(text=f"Result: {money}.\nClick the Flip button to start over.", bg="#fffaaa")
money = 100 # reset
root = Tk()
root.title("Game")
# the text here changes when the buttons are pressed
text = Label(root, text="Welcome to the Flip and Spin game!", font = ("Calibri", "18"))
text.pack()
rules = Label(root, text="This game includes a quick fate of what you could encounter. \nIt starts off with a fast flip of a coin followed by a dizzying spin of a spinner. \nCome and play to decide if you will lose money, \nmake your money back, or win some easy money!", font = ("Calibri", "10"))
rules.pack()
# click the button to run the command and change the text in the Label
flip_button = Button(root, text="Flip", command=coin_flip, fg="blue")
flip_button.pack(fill=X, side=LEFT, expand=True)
# click the button to run the command and change the text in the Label
result_button = Button(root, text="Result", command=show_result, fg="blue")
result_button.pack(fill=X, side=RIGHT, expand=True)
root.mainloop()

how do I change my counter's speed on tkinter?

I would like to make a money counter with a input box that changes the speed of the counter to display the inputed amount of money per hour, however it's very choppy and doesn't seem to work with different numbers. any advice?
import tkinter as tk
root = tk.Tk()
money = 0
money_per_hour = 1000
root.minsize(500,300)
def monies():
global money_per_hour
box = spinbox.get()
box = int(box)
final = 3600/box
final = round(final)
final = final * 1000
money_per_hour = final
countup()
button = tk.Button(text = "show me the money", fg = "green", command = monies)
button.pack(side = "bottom")
spinbox = tk.Spinbox(from_=0, to=1000000, width=5)
spinbox.pack(side = "bottom")
label = tk.Label(root, text = "$" + str(money), foreground = "green", font = ('calibri', 40, 'bold'))
label.pack()
def countup():
global money
money += 1
label['text'] = "$" + str(money)
root.after(money_per_hour, countup)
root.after(money_per_hour, countup)
root.mainloop()

Is there a way to clear the canvas if using tkinter and writing on it again with a different message?

I have created a game it uses tkinter to open a GUI. It has a timer and when the timer runs out I want it to clear the GUI and have a message for example: Time up, you scored + there score.
I have been able to make a label that does this on the GUI but just stays there even if the timer doesnt = 0.
Here is the source code:
import tkinter
import random
colours = ['Red','Blue','Green','Pink','Black','Yellow','Orange','White','Purple','Brown']
score=0
timeleft=30
def startGame(event):
if timeleft == 30:
countdown()
nextColour()
def nextColour():
global score
global timeleft
if timeleft > 0:
e.focus_set()
if e.get().lower() == colours[1].lower():
score += 1
e.delete(0, tkinter.END)
random.shuffle(colours)
label.config(fg=str(colours[1]), text=str(colours[0]))
scoreLabel.config(text="Score: " + str(score))
def countdown():
global timeleft
if timeleft > 0:
timeleft -= 1
timeLabel.config(text="Time left: " + str(timeleft))
timeLabel.after(1000, countdown)
if timeleft == 0:
canvas.delete("all")
endGame.config(text="Time up, you scored " + str(score))
root = tkinter.Tk()
root.title("TTCANTW")
root.geometry("375x250")
instructions = tkinter.Label(root, text="Type in the colour of the words, and not the word text!", font=('ariel', 12))
instructions.pack()
endGame = tkinter.Label(root, text="Time up, you scored " + str(score), font=('ariel', 12))
endGame.pack()
scoreLabel = tkinter.Label(root, text="Press enter to start", font= ('Helvetica', 12))
scoreLabel.pack()
timeLabel = tkinter.Label(root, text="Time left: " + str(timeleft), font=('Helvetica', 12))
timeLabel.pack()
label = tkinter.Label(root, font=('Helvetica', 60))
label.pack()
e = tkinter.Entry(root)
root.bind('<Return>', startGame)
e.pack()
e.focus_set()
root.mainloop()
Thanks in advance
You don't have canvas widget, impossible to delete
you have to use destroy to delete every widgets you want to delete..
I edited your function
def countdown():
global timeleft
if timeleft > 0:
timeleft -= 1
timeLabel.config(text="Time left: " + str(timeleft))
timeLabel.after(1000, countdown)
if timeleft == 0:
#canvas.delete("all")
instructions.destroy()
timeLabel.destroy()
label.destroy()
e.destroy()
#-------------------------
endGame.config(text="Time up, you scored " + str(score))

Categories