From f70fbc526a92d57f3c68e61d4efe2255fdade7d3 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Wed, 25 Jul 2018 19:00:51 +0200 Subject: [PATCH] More complete example editor --- examples/designer.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/examples/designer.py b/examples/designer.py index 5ccdb50..17551ed 100644 --- a/examples/designer.py +++ b/examples/designer.py @@ -1,9 +1,42 @@ from kivy.app import App +from kivy.lang import Builder +from kivy.uix.button import Button +from kivy.uix.label import Label from kivyforms import FormCanvas +screen = Builder.load_string(''' +BoxLayout: + orientation: 'horizontal' + FormCanvas: + id: form_canvas + BoxLayout: + size_hint: 0.2, 1 + orientation: 'vertical' + Button: + text: 'Add button' + on_press: app.add_button() + Button: + text: 'Add label' + on_press: app.add_label() +''') + class DesignerApp(App): + button_id = 0 + label_id = 0 + + def on_start(self): + self.form_canvas = self.root.ids.form_canvas + + def add_button(self): + self.button_id += 1 + self.form_canvas.add_widget(Button(text='Button ' + str(self.button_id))) + + def add_label(self): + self.label_id += 1 + self.form_canvas.add_widget(Label(text='Label ' + str(self.label_id))) + def build(self): - return FormCanvas() + return screen if __name__ == '__main__': app = DesignerApp() -- 2.39.5