P
P
pavuuuk2019-12-14 12:21:41
Python
pavuuuk, 2019-12-14 12:21:41

How to get widget from kv file?

Let's say I have a kv file with many boxlayouts and various other layouts, how do I get one of them to work with in index.py?

<MainScreen>:
    BoxLayout:
        BoxLayout:
            # Нужно получить этот BoxLayout в python коде
            Button:
                text = "Button"

from kivy.app import App
from kivy.core.window import Window
from kivy.lang.builder import Builder
from kivy.uix.boxlayout import BoxLayout

Window.clearcolor = (.98, .98 ,.98, 1)

class MainScreen(BoxLayout):
    pass

presentation = Builder.load_file("main.kv")

class MainApp(App):
    def build(self):
        return presentation

if __name__ == "__main__":
    MainApp().run()

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question