Reputation: 439
I am having a problem running a loop that will auto update some stuff. (Like game money) It is supposed to add 100 dollars every 30 seconds. The Gui won't load, but the shell does not give me any errors. Thanks in advance!
def update():
while True:
money = money + 100
label.set(str(money))
time.sleep(30)
Upvotes: 1
Views: 1610
Reputation: 22041
Try writing your function this way instead. You should be scheduling your code to run, not looping it.
def update(money=0, increase=100, repeat=30):
money += increase
label.set(money)
label._master.after(repeat * 1000, update, money, increase, repeat)
Upvotes: 2