#grid.py
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
class MyGrid(GridLayout):
def __init__(self):
super(MyGrid, self).__init__()
self.cols = 1
self.inside = GridLayout()
self.inside.cols = 2
self.inside.add_widget(Label(text="First Name: "))
self.firstname = TextInput(multiline=False)
self.inside.add_widget(self.firstname)
self.inside.add_widget(Label(text="Last Name: "))
self.lastname = TextInput(multiline=False)
self.inside.add_widget(self.lastname)
self.inside.add_widget(Label(text="Email: "))
self.email = TextInput(multiline=False)
self.inside.add_widget(self.email)
self.add_widget(self.inside)
self.submit = Button(text="Submit", font_size=40)
self.submit.bind(on_press=self.pressed)
self.add_widget(self.submit)
def pressed(self, instance):
name = self.firstname.text
last = self.lastname.text
email = self.email.text
print("First Name:", name, "last Name", last, "email:", email)
class MyApp(App):
def build(self):
return MyGrid()
MyApp().run()
reference:
No comments:
Post a Comment