Answer the question
In order to leave comments, you need to log in
Mystery of Python GUI (Kivy) and Multiprocessing?
Here is my simple code that, when the button is clicked, should run the run_bot() function :
from kivy.app import App
from kivy.uix.button import Button
import multiprocessing as mp
import time
def run_bot():
while True:
print('Working...')
time.sleep(2)
class MyApp(App):
def build(self):
self.btn=Button(
text='Старт',
font_size=30,
on_press=self.start,
background_color=(1,3,3,10)
)
return self.btn
def start(self,instance):
self.proc=mp.Process(target=run_bot)
self.proc.daemon=True
self.proc.start()
if __name__ == '__main__':
MyApp().run()
Answer the question
In order to leave comments, you need to log in
In pyinstaller (and other "compilers") for multiprocessor applications, you need to do it mp.freeze_support()
right after if __name__ == '__main__':
.
But such actions are still entertainment, in the future something else will fall off
https://docs.python.org/3/library/multiprocessing....
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question