#project structure
grid.kv
gridkv.py
#gridkv.py
import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from kivy.uix.widget import Widget
class Grid(Widget):
def btn(self):
print("Name:", self.ids["name_id"].text, "Email:", self.ids["email_id"].text)
class GridApp(App):
def build(self):
return Grid()
GridApp().run()
-----------------
#grid.kv
<Grid>
GridLayout:
cols: 1
size: root.width - 200, root.height - 200
pos: 100, 100
GridLayout:
cols:2
Label:
text: "Name: "
TextInput:
id: name_id
multiline:False
Label:
text: "Email: "
TextInput:
id: email_id
multiline:False
Button:
text:"Submit"
on_press: root.btn()
-----------------
#logs
Name: ab Email: cd
reference:
No comments:
Post a Comment