lundi 22 février 2021

If statement not working as it should in Python 3

I'm trying to print out a string when the score is at greater than or equal to 5 but it won't print. What am I doing wrong here?

from tkinter import *

top = Tk()
top.geometry("1000x720")

Score = 0

var = StringVar()
sline = Label(top, textvariable=var)
sline.place(x = 100, y = 395)
var.set("Score: ")

scorevar = StringVar()
label = Label(top, textvariable=scorevar)
label.place(x = 140, y = 395)
scorevar.set("0")



def getscore():
    global Score
    Score = Score + 1
    scorevar.set(Score)
    print(Score)

bclick = Button(top, fg='white', bg='RoyalBlue3', activebackground='azure', highlightcolor='azure', bd=4, padx=10, pady=5, text = "Click!", command = getscore)
bclick.place(x = 100,y = 350)

if Score >= 5:
    print("Hey, you're rich now!")

top.mainloop()

Aucun commentaire:

Enregistrer un commentaire