I am trying to create an animation. The major libraries I use are Tkinter and Threads.
Function1{
while 1{
#code
}
}
function2{
#one button element
#if button element is clicked
# create a thread object to invoke the Function 1
}
I am facing a problem that while running the program, sometimes it shows interface and then gets stucks and sometimes it just runs smoothly.
I also have a stop button to exit thread. In that I am setting a variable value to 1 such that when this variable is checked for value change in the thread the while loop get breaked. Is that the best way to exit a thread??
tkinter isn't thread safe. See this answer for an example of doing simple animation without threads.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.