我正在尝试运行一个 while 循环来更改我的代码中的变量,但它只会破坏我的代码。我不知道该怎么做。当我改变 T 而不重复命令时,我希望 X 改变。
import tkinter
from tkinter import *
code = Tk()
T = 1
X = 0
def printx():
global X
print(X);
def teez():
global T
T = 0;
def teeo():
global T
T = 1;
while T == 1:
X = 5
else:
X = 6
button1 = Button(code, text = "Print X", command = printx)
button1.pack()
button2 = Button(code, text = "T = 0", command = teez)
button2.pack()
button2 = Button(code, text = "T = 1", command = teeo)
button2.pack()
code.mainloop()
PS它在python 3.7中
相关分类