I want to stop a thread if I press a button on my window but I didn't found how to do it, can someone help me ?
I have something like this for the thread class :
class myThread (threading.Thread):
def __init__(self, source_file, thread_number):
threading.Thread.__init__(self)
#self Var#########################
self.source_file = source_file
self.thread_number = thread_number
##################################
def run(self):
print("Thread"+str(self.thread_number)+" has begun\n\r")
#Function that will be run########
#Start Manager
self.manager.start(self.source_file)
#Stop Manager
self.manager.stop(self.log_file)
print("Thread"+str(self.thread_number)+" has stopped\n\r")
I call a thread when I press on a start button :
print("Thread creation \n\r")
self.thread = myThread(self.source_file, self.thread_number)
self.thread.start()
And I associated a function with my "Stop" button which is :
def stop(self):
######################################
#Function to stop the thread here ...#
######################################
#Stop Manager
self.manager.stop(self.log_file)
print("Thread"+str((self.thread_number)-1)+" has stopped in stop()\n\r")
Thank you.