I am trying to create a GUI that communicates with a RS232 serial object. I’ll present an analogous scenario to the problem that I am facing. I want to create a frame with 2 buttons, Start and Stop. The start button calls the ‘foo’ function:
status = True
def foo():
n = 0
while(getStatus()):
print n
n += 1
sleep(0)
This foo function keeps running until I press stop.
def getStatus():
return status
def stop():
status = False
I understand Tkinter is single-threaded and once I press ‘Start’, the GUI will freeze. I know this is possible with the after function, but i strictly want to use threading. Is this possible with threading? If so can you please provide a sample code? Thank you.
here is some (not yet perfect) code:
What is missing/broken, but you did not ask for this, I added links:
Also for stopping threads look here