I have created a GUI with PysimpleGUI that has multiple buttons, the intentionss is that users click on a button and continue to work on othe task while the action on the first clicked button is running, and when the action of the clicked button finished, then the thread exits (distroys the current thread),
the code is throwing : RuntimeError: main thread is not in main loop
Can someone help me create the _thread.start_new_thread process and incorporated to the main loop or maybe a solution to avoid RuntimeError
for threading i am using : _thread
the code:
class Windows:
def newOpenGraph(self, window, event, values):
'''
opens a new graph with no problem
'''
def newThread(self, window, event, values):
isRunning = True
if event == 'OPEN GRAPH':
_thread.start_new_thread(self.newOpenGraph, (window, event, values ))
isRunning = False
while isRunning:
schedule.run_pending()
time.sleep(1)
def mainLayout(self):
'''
layout frame work
'''
while True:
event, values = window.read()
if event == 'OPEN GRAPH':
# self.newOpenGraph(window, event, values)
self.newThread(window, event, values)
the image:
