# 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
class MyGrid(GridLayout):
def __init__(self, **kwargs): # 初屎化方法
super(MyGrid, self).__init__(**kwargs) # 加一个关键字参数方便传参
self.cols = 2 # 列
self.add_widget(Label(text="you name:")) # # 添加一个标签
self.username = TextInput(multiline=False) # 用户名输入框
self.add_widget(self.username) # 将用户名输入框添加至布局
self.add\_widget(Label(text='password:')) # 添加一个标签
self.password = TextInput(password=True, multiline=False) # password是否显示密码 multiline是否多行
self.add\_widget(self.password)
class MyApp(App):
def build(self):
return MyGrid()
if __name__ == "__main__":
MyApp().run()
手机扫一扫
移动阅读更方便
你可能感兴趣的文章