I am using the Kivy python library.
I have two widgets.
When the program starts, I launch the first widget.
When this widget button is pressed, I want it to disappear and be replaced by a second widget.
Here is the .kv for two widgets
#uitest.kv <TestForm>: canvas: Rectangle: pos: self.center_x, 0 size: 10, self.height BoxLayout: size: root.size padding: 40 Button: text: 'Hello' on_release: root.testCallback() <TestForm2>: canvas: Rectangle: pos: self.center_x, 0 size: self.height, 10
My main python file launches the application and returns the first widget
#main.py from testform import TestForm from kivy.app import App class UITestApp(App): def build(self): return TestForm()
My first widget has a callback. Here is the code in question
from testform2 import TestForm2 from kivy.uix.widget import Widget class TestForm(Widget): def testCallback(self): TestForm2()
The idea here is to have a user interface manager. This manager does not start the interface like a tree, but like a list and a stack. The list contains instances of all my user interfaces. The stack keeps going around the indicated forms, whenever we move to the form, we push it toward the stack and βvisualizeβ or something else.
EDIT: I chose my answer, but in my searches I also found a Screen object: http://kivy.org/docs/api-kivy.uix.screenmanager.html Personally, the clear () and add () commands are more powerful, but the screen takes a lot from your hands if you're interested. Transition effects too.
Mintyant
source share