event handling - Python Kivy: Properly start a background process that updates GUI elements -


I have a Python script that makes some deep processing of user files and can take some time I used Kiwi To create a user interface, which allows the user to choose the file, processing mode, and shows some messages when the process is turned on.

My problem is that when the main Kiwi loop calls the nearby user interface, the window is free.

The correct way to solve what I have understood is creating a separate process in which the script will be off-loaded and send updates of user interface.

However, I have no idea how to send the messages back to the application from a different thread or how to do it or there was no instance of it.

Anyone please do this properly or point me in the documents related to this topic?

Update:

To make the program sustainable, I would like to avoid calling the elements of processor loops from the main thread and instead one Call long process which returns to the updated elements of the GUI such as progress bar or text field. It seems that those elements can only be modified with the main Kiwi thread. How can I get them out from the outside?

Describe the publisher / consumer model as described. An example of a modified link to use different threads is given here: kivy.app import from kivy.clock import by app clock, _default_time # as a timeline, there is no better way to use the same clock Import from Kivy.lang import from importer builder kivy.factory import from factory kivy.uix.button import button from kivy.properties import thread importing import time from time imported sleep from threads MAX_TIME = 1/60 kv = '' 'box layout: scrollview : Grid Layout: Columns 1 ID: Target Akar_hnt: 1, any height not self. MinimumHighlight: Text: 'Run' & lt; MyLabel @ Label & gt;: size_hint_y: no height: self.texture_size [1] '' class MyButton (button): def on_press (auto, * args): thread (target = self.worker). Start () def worker (self): SO (5) # Blocked operation App.get_running_app (): Clock.schedule_interval (self.consume, 0) Returns Builder.load_string (kv) def uses (self, * Args): While self Consumables and Time () & lt; (Clock.get_time () + MAX_TIME): items = self.consommables.pop (0) # I have a label = factory first. MyLabel (text = item) wants self.root.ids.target.add_widget (label) if __name__ == '__man__': pubConf (). Run ()

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -