小编red*_*ish的帖子

如果语句在 Python 3 中无法正常工作

当分数大于或等于 5 时,我试图打印出一个字符串,但它不会打印。我在这里做错了什么?

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, …
Run Code Online (Sandbox Code Playgroud)

python if-statement tkinter python-3.x

-3
推荐指数
1
解决办法
57
查看次数

标签 统计

if-statement ×1

python ×1

python-3.x ×1

tkinter ×1