I
I
irdaxirdaxirdax2020-07-19 12:21:41
Python
irdaxirdaxirdax, 2020-07-19 12:21:41

Add KV Kivy elements?

Hello.
There is a code:

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen

kv_string = """
<Start>
  Button:
    text: "Hello"

  """

Builder.load_string(kv_string)



class Start(Screen):
  kv_string = kv_string + """\n        Button:\n                text: 'Bye'"""


sm = ScreenManager()
sm.add_widget(Start(name="Start"))

class MainApp(App):
  def build(self):
    return sm
    root.manager.current = "Start"



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

In it, I'm trying to add another Button element.
But in the end, only the "Hello" button appears.
How can I add multiple elements after Builder.load_string?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
irdaxirdaxirdax, 2020-07-19
@irdaxirdaxirdax

It's decided.
After kv_string = kv_string + ..... added Builder.load_string

J
Just Python's sheep, 2020-07-19
@Dime38

Is that even possible? In my opinion, no)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question