Kivy runs an event loop, the event loop is effectively an infinite loop looking for events to process. You have launched an infinite loop inside an infinite loop.
The kivy instance that you launched the other copy of kivy from is running the main event loop, the “hello world” is running another event loop.
What is it you want to accomplish?
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/c2b5bf1e-8833-4b4e-acaf-111f8cbe1455n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/f7766685-b7a3-4154-a22a-a75178465416n%40googlegroups.com.
What do you need help with?
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAC4rABptH5vuTdoHSBasKZ%3DFn5BwTGqav39MSxp-twwB-2%3D4zA%40mail.gmail.com.
Yes. Look at what the reset code I sent is doing. It is launching a new program.
Put your ‘child’ kivy program in a separate file, and use the appropriate os.exec to run it.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/473c122f-facb-4b19-b1d1-a1ec8510a910n%40googlegroups.com.
Here is an example:
Main.py
from kivy.lang import Builder
from kivy.app import App
import os
import sys
kv = '''
Button:
text: 'launch hello'
on_press:app.go()
'''
class TestApp(App):
def build(self):
return Builder.load_string(kv)
def go(self):
os.execlp(sys.executable, 'python', 'hello.py')
TestApp().run()
Hello.py:
from kivy.app import App
from kivy.uix.button import Button
class TestApp(App):
def build(self):
return Button(text='Hello World')
TestApp().run()
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/622cc938.1c69fb81.43e25.d078SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
I realized the call can be simplified to:
os.execlp('python', 'python', 'hello.py')
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/622cd42d.1c69fb81.d300f.6feeSMTPIN_ADDED_MISSING%40gmr-mx.google.com.
At a high level, what is it you are trying to achieve?
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/f567a1db-a95c-453a-935d-ea26a7a475e6n%40googlegroups.com.
If you want to create an interactive KV compiler, take a look at the “kivy catalog” in the examples directory.
You may want to look at the source code for IDLE. https://github.com/python/cpython/tree/main/Lib/idlelib
If you want a more full featured system that will handle python and KV, creating a new window while the existing window is open, I think you will need to use multi-processing. https://docs.python.org/3/library/multiprocessing.html
There are some non obvious things to watch for when using multi-processing. I documented a few learnings writing a multi-processing kivy app:
See: https://github.com/ElliotGarbus/MidiClockGenerator
This app uses MP to create a high resolution, low jitter timer in another process. __name__ will get a different name in the process that is created by the program (__mp_main__). The test "if __name__ == '__main__':" prevents the kivy UI code from being loaded in both processes.
Subprocess maybe a simpler alternative to the Multi-processing library, that would work for your use case. See: https://docs.python.org/3/library/subprocess.html
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/079a007c-c5cf-4d24-937b-c0e0eef650a8n%40googlegroups.com.