【发布时间】:2021-07-12 00:23:24
【问题描述】:
这个 .kv 文件我通过Builder.load_file('style.kv') lode Kivy 文件
ScreenManager:
Sign_in:
Sign_up:
<Sign_in>:
name: 'sign in'
MDScreen:
id: sign_in
md_bg_color: [35/255, 59/255, 54/255, 1]
MDCard:
size_hint: None, None
size: 320, 400
pos_hint: {"center_x":.5, "center_y":.5}
elevation: 15
md_bg_color: [35/255, 49/255, 48/255, 1]
padding: 20
spacing: 30
orientation: "vertical"
MDLabel:
text: "LOGIN"
font_style: 'Button'
font_size: 45
halign: "center"
size_hint_y: None
height: self.texture_size[1]
padding_y: 15
MDTextFieldRound:
id: username
hint_text: "username"
icon_right: "account"
size_hint_x: None
width: 220
pos_hint: {"center_x":.5}
color_active: [1,1,1,1]
MDTextFieldRound:
id: Pass
hint_text: "Password"
icon_right: "eye-off"
size_hint_x: None
width: 220
pos_hint: {"center_x":.5}
password: True
color_active: [1,1,1,1]
MDTextFieldRound:
id: Email
hint_text: "Email Id"
icon_right: "email"
size_hint_x: None
width: 220
pos_hint: {"center_x":.5}
password: True
color_active: [1,1,1,1]
MDRoundFlatButton:
text: "Sign In"
pos_hint: {"center_x":.5}
font_size: 15
on_press: app.show_data()
Widget:
size_hint_y: None
height: 30
<Sign_up>:
name: 'sign up'
我尝试了很多东西,但没有解决这个错误.py文件如何解决?
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen, ScreenManager
class Sign_in(Screen):
pass
class Sign_up(Screen):
pass
se = ScreenManager()
se.add_widget(Sign_in(name='sign in'))
se.add_widget(Sign_up(name='sign up'))
class Chatting(MDApp):
def build(self):
return Builder.load_file('style.kv')
def show_data(self):
print(self.root.ids.username.text)
if __name__ == '__main__':
Chatting().run()
【问题讨论】:
标签: python kivy mobile-application kivymd