Kivy - Automatically Start A Method From Popup
PROBLEM I am using Python3 and Kivy2. Regardless I would like a popup to automatically start a time consuming method in the background DESCRIPTION In the script call for the popup
Solution 1:
Using the join()
method of a Thread
causes a wait until that Thread
has completed, which is almost equivalent to not using threading
.
Try eliminating thread t1
, and just call popup
without using a new thread for that. Then start thread t2
, but eliminate the t2.join()
call.
Solution 2:
ANSWER
The answer proposed @John Anderson was helpful. The join method causes an undesired wait.
First I tried to run the def popup
method as the lead and the time_consuming_method
as a thread. This approach did not solved the problem.
NOT WORKING CODE
defpopup(self, boxTitle, boxLabel): # popup for showing the activity
self.MessageBoxTitle = boxTitle
self.MessageBoxLabel = boxLabel
self.popup = ActivityBox(self)
self.popup.open()
self.popup(boxTitle, boxLabel)
t2 = threading.Thread(target = time_consuming_method)
t2.start()
Then I tried running self.popup.open()
method as the lead and the the time_consuming_method
as a thread from inside the def popup
method. This solution worked out fine, the popup appears when the method starts.
WORKING CODE
defpopup(self, boxTitle, boxLabel): # popup for showing the activity
self.MessageBoxTitle = boxTitle
self.MessageBoxLabel = boxLabel
self.popup = ActivityBox(self)
self.popup.open() # call the popup
t2 = threading.Thread(target = time_consuming_method) # define the thread
t2.start() # start the thread
Post a Comment for "Kivy - Automatically Start A Method From Popup"