|
| 1 | +import kivy |
| 2 | +from kivy.app import App |
| 3 | +from kivy.uix.gridlayout import GridLayout |
| 4 | +from kivy.uix.label import Label |
| 5 | +from kivy.uix.textinput import TextInput |
| 6 | +from kivy.uix.button import Button |
| 7 | + |
| 8 | +class childApp(GridLayout): |
| 9 | + def __init__(self,**kwargs): |
| 10 | + super(childApp, self).__init__() |
| 11 | + self.cols = 2 |
| 12 | + self.add_widget(Label(text = 'Student Name')) |
| 13 | + self.s_name = TextInput() |
| 14 | + self.add_widget(self.s_name) |
| 15 | + |
| 16 | + |
| 17 | + self.add_widget(Label(text = 'Student Marks')) |
| 18 | + self.s_marks = TextInput() |
| 19 | + self.add_widget(self.s_marks) |
| 20 | + |
| 21 | + |
| 22 | + self.add_widget(Label(text = 'Student Gender')) |
| 23 | + self.s_gender = TextInput() |
| 24 | + self.add_widget(self.s_gender) |
| 25 | + |
| 26 | + self.press = Button(text = 'Click me') |
| 27 | + self.press.bind(on_press = self.click_me) |
| 28 | + self.add_widget(self.press) |
| 29 | + |
| 30 | + def click_me(self, instance): |
| 31 | + print("Name of the Student is "+self.s_name.text) |
| 32 | + print("Marks of the Student is "+self.s_marks.text) |
| 33 | + print("Gender of the Student is "+self.s_gender.text) |
| 34 | + print("") |
| 35 | + |
| 36 | + |
| 37 | +class parentApp(App): |
| 38 | + def build(self): |
| 39 | + return childApp() |
| 40 | + |
| 41 | +if __name__ == "__main__": |
| 42 | + parentApp().run() |
0 commit comments