from Tkinter import *
from threading import Thread
from time import sleep
def call_at_interval(period, callback, args):
while True:
sleep(period)
try:
callback(*args)
except:
exit(0)
def setInterval(period, callback, *args):
Thread(target=call_at_interval, args=(period, callback, args)).start()
def go():
print("count")
setInterval(3,count,5)
def count(val):
i[0] = i[0] + 1
print(i)
if(i[0]%val == val-1):
f2.tkraise()
elif(i[0]%val==0):
f1.tkraise()
i = []
i.append(1)
root = Tk()
f1 = Frame(root)
f2 = Frame(root)
for frame in (f1,f2):
frame.grid(row=0, column=0, sticky='news')
f1.tkraise()
b = Button(f1,text="changeframe",command=go)
b.pack()
root.mainloop()
The all i want is to raise a frame from a function which is running on a certain interval of time during specific condition.An example is above.There is a problem in above example that when value of i[0]
reach the val-1
it the setInterval stops and the application gives "not respondng error".Please any help me to short out this problem.