먼저 몇 개의 버튼이있는 창을 만들고 명령을 정의했습니다. while 루프를 추가하여 아무 버튼이 눌러 졌는지 확인한 다음 다음 단계로 이동하기 전까지는 모두 잘 작동합니다. 그러나 그때 창은 나타나지 않고 루프는 영원히 달리고 있습니다. 나는 또한 내 코드에 대한 더 나은 대안이 있는지 알고 싶다.루프 while (파이썬 3)
from tkinter import *
Round = 0
def blackC():
global Round
print ('0')
x = 0
Round += 1
def brownC():
global Round
print ('1')
x = 1
Round +=1
def redC():
global Round
print ('2')
x = 2
Round += 2
def win():
window = Tk()
window.geometry ('500x500')
window.title('HELLO')
blackB = Button(text = 'BLACK', command=blackC, width=7, height=3, bd=5)
blackB.place(x=1, y=1)
brownB = Button(text = 'BROWN', command=brownC, width=7, height=3, bd=5)
brownB.place(x=86, y=1)
redB = Button(text = 'RED', command=redC, width=7, height=3, bd=5)
redB.place(x=172, y=1)
window.mainloop()
while (Round == 0):
win()
while (Round < 3):
if (Round == 1):
y = x * 10
print ('y')
elif (Round == 2):
y += x
print ('y')
고마워요.하지만 여전히 내 문제를 해결하지 못합니다. –
정말 알아야 할 것이 있습니까? – knezi
변수 값 x와 Round 값을 변경할 수있는 몇 개의 버튼이있는 windoe가 있습니다. 그런 다음 round 값이 특정 숫자에 도달했는지 확인한 다음 while 루프가 있습니다. 단계. 그러나 while 문은 창을 닫을 때까지 실행되지 않습니다. –