]> git.jsancho.org Git - kivyforms.git/commitdiff
More widgets in the example master
authorJavier Sancho <jsf@jsancho.org>
Tue, 31 Jul 2018 10:41:16 +0000 (12:41 +0200)
committerJavier Sancho <jsf@jsancho.org>
Tue, 31 Jul 2018 10:41:16 +0000 (12:41 +0200)
examples/designer.py

index adeb2cbc3f8999212070283b735fd31331023232..cce34443367dd362e3e67818f94febcb7e31bc05 100644 (file)
@@ -1,7 +1,10 @@
 from kivy.app import App
 from kivy.lang import Builder
 from kivy.uix.button import Button
+from kivy.uix.checkbox import CheckBox
 from kivy.uix.label import Label
+from kivy.uix.textinput import TextInput
+from kivy.uix.togglebutton import ToggleButton
 from kivyforms import FormCanvas
 
 screen = Builder.load_string('''
@@ -15,9 +18,18 @@ BoxLayout:
         Button:
             text: 'Add button'
             on_press: app.add_button()
+        Button:
+            text: 'Add checkbox'
+            on_press: app.add_checkbox()
         Button:
             text: 'Add label'
             on_press: app.add_label()
+        Button:
+            text: 'Add text input'
+            on_press: app.add_textinput()
+        Button:
+            text: 'Add toggle button'
+            on_press: app.add_togglebutton()
         Button:
             text: 'Export to Kv'
             on_press: app.export_to_kv()
@@ -26,6 +38,7 @@ BoxLayout:
 class DesignerApp(App):
     button_id = 0
     label_id = 0
+    togglebutton_id = 0
 
     def on_start(self):
         self.form_canvas = self.root.ids.form_canvas
@@ -34,10 +47,20 @@ class DesignerApp(App):
         self.button_id += 1
         self.form_canvas.add_widget(Button(text='Button ' + str(self.button_id)))
 
+    def add_checkbox(self):
+        self.form_canvas.add_widget(CheckBox())
+
     def add_label(self):
         self.label_id += 1
         self.form_canvas.add_widget(Label(text='Label ' + str(self.label_id)))
 
+    def add_textinput(self):
+        self.form_canvas.add_widget(TextInput())
+
+    def add_togglebutton(self):
+        self.togglebutton_id += 1
+        self.form_canvas.add_widget(ToggleButton(text='Toggle Button ' + str(self.togglebutton_id)))
+
     def export_to_kv(self):
         print(self.form_canvas.export_to_kv())