1

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??

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
ranger
  • 63
  • 1
  • 7

1 Answers1

0

tkinter isn't thread safe. See this answer for an example of doing simple animation without threads.

Community
  • 1
  • 1
Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685