Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from kivy.app import App
- from kivy.lang import Builder
- from kivy.uix.screenmanager import ScreenManager, Screen
- from kivy.properties import StringProperty
- kv = """
- #: import NoTransition kivy.uix.screenmanager.NoTransition
- <Label>
- size_hint: (None, None)
- width: 200
- height: 50
- <TextInput>
- size_hint: (None, None)
- width: 200
- height: 50
- multiline: False
- write_tab: False
- <MainMenu>
- GridLayout:
- Button:
- text: "Add to Database"
- size: root.width * .2, root.height * .05
- pos: root.width * .05, root.height * .8
- font_size: root.height * .035
- on_release:
- root.manager.transition = NoTransition()
- root.manager.current = "DatabaseAdd"
- Button:
- text: "Search Database"
- size: root.width * .2, root.height * .05
- pos: root.width * .05, root.height * .7
- font_size: root.height * .035
- on_release:
- root.manager.transition = NoTransition()
- root.manager.current = "SearchDatabase" # change to root.manager.current
- <DatabaseAdd>
- name: "DatabaseAdd"
- name_first: id1
- name_last: id2
- #id3: id3
- #id4: id4
- #id5: id5
- #id6: id6
- #id7: id7
- #id8: id8
- AnchorLayout:
- width: root.width
- height: root.height
- ScrollView:
- do_scroll_y: True
- do_scroll_x: False
- size_hint: (None, None)
- size: (root.width * .8, root.height * .8)
- #width: root.width * .80
- #height: root.height * .8
- anchor_x: "center"
- anchor_y: "center"
- GridLayout:
- cols: 1
- GridLayout:
- cols: 4
- size_hint_y: None
- height: self.minimum_height
- Label:
- #text: "First Name"
- text: root.id1Label # changed to root, and moved property
- TextInput:
- id: id1
- Label:
- text: "Last Name"
- TextInput:
- id: id2
- #Label:
- #text: "Value 3"
- #TextInput:
- #id: id3
- #Label:
- #text: "Value 4"
- #TextInput:
- #id: id4
- #Label:
- #text: "Value 5"
- #TextInput:
- #id: id5
- #Label:
- #text: "Value 6"
- #TextInput:
- #id: id6
- #Label:
- #text: "Value 7"
- #TextInput:
- #id: id7
- #Label:
- #text: "Value 8"
- #TextInput:
- #id: id8
- BoxLayout:
- size_hint: None, None
- size: self.minimum_size
- Label:
- width: (root.width * .8)/5
- Button:
- text: "Submit"
- width: (root.width * .8)/5
- on_press: root.press()
- Label:
- width: (root.width * .8)/5
- Button:
- text: "Clear"
- width: (root.width * .8)/5
- on_press: root.clear()
- Label:
- width: (root.width * .8)/5
- <SearchDatabase>:
- Label:
- size_hint: 1, 1
- text: 'Placeholder for search database'
- WindowManager:
- MainMenu:
- DatabaseAdd:
- SearchDatabase:
- name: "SearchDatabase"
- """
- class WindowManager(ScreenManager):
- pass
- class MainMenu(Screen):
- pass
- class DatabaseAdd(Screen):
- id1Label = StringProperty('First Name')
- # def __init__(self, **kwargs): # __init__ ? Not sure what you want to do here
- # super().__init__(**kwargs)
- # self.id1Label = StringProperty("First Name") Property must be at class level
- #
- def press(self):
- name_first = self.name_first.text
- name_last = self.name_last.text
- print(name_first, name_last)
- self.clear()
- def clear(self):
- self.name_first.text = ""
- self.name_last.text = ""
- class SearchDatabase(Screen):
- pass
- class MainApp(App):
- def build(self):
- return Builder.load_string(kv)
- if __name__ == "__main__":
- MainApp().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement