How To Make "stop" Button To Terminate "start" Function Already Running In Tkinter (python)
I am making a GUI using Tkinter with two main buttons: 'Start' and 'Stop'. Could you, please, advise on how to make the 'Stop' button to terminate the already running function call
Solution 1:
why do you think using threads would be a solution? ...
you cannot stop a thread/process even from the main process that created/called it. (at least not in a mutliplatform way ... if its just linux thats a different story)
instead you need to modify your Ostap_process_twitter_file_folder.start_extraction()
to be something more like
halt_flag = Falsedefstart_extraction(self):
whilenot Ostap_process_twitter_file_folder.halt_flag:
process_next_file()
then to cancel you just do Ostap_process_twitter_file_folder.halt_flag=True
oh since you clarified i think you just want to run it threaded ... I assumed it was already threaded ...
def start(evt):
th = threading.Thread(target=Ostap_process_twitter_file_folder.start_extraction)
th.start()
return th
Post a Comment for "How To Make "stop" Button To Terminate "start" Function Already Running In Tkinter (python)"