【发布时间】:2021-01-24 15:00:57
【问题描述】:
我只是在学习,我尝试运行这个简单的代码: 我有问题,我们能帮帮我吗: 这是我的应用程序代码:
from kivymd.app import MDApp
from kivy.lang.builder import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
Screen_helper = """
ScreenManager:
MenuScreen:
InscriptionScreen:
LoginScreen:
<MenuScreen>:
name: 'menu'
MDRectangleFlatButton:
text: 'Inscription'
pos_hint: {'center_x':0.5,'center_y':0.6}
on_press: root.manager.current = 'Inscription'
MDRectangleFlatButton:
text: 'Login'
pos_hint: {'center_x':0.5,'center_y':0.5}
on_press: root.manager.current = 'Login'
<InscriptionScreen>:
name: 'Inscription'
MDLabel:
text: "Inscription"
pos_hint: {"center_y": .85}
font_style:"H4"
halign : "center"
theme_text_color : "Custom"
text_color : 0, 0, 0, 1
MDTextField:
hint_text: "Enter First Name"
icon_right:"account"
pos_hint:{'center_x':0.5,'center_y':0.7}
size_hint_x:None
width:300
MDTextField:
hint_text: "Enter Last Name"
icon_right : "account"
pos_hint:{'center_x':0.5,'center_y':0.6}
size_hint_x:None
width:300
MDTextField:
hint_text: "Enter Email"
icon_right: "mail"
pos_hint: {'center_x': 0.5, 'center_y': 0.5}
size_hint_x: None
width: 300
MDTextField:
hint_text: "Enter Username"
icon_right:"account-plus"
pos_hint:{'center_x':0.5,'center_y':0.4}
size_hint_x:None
width:300
MDTextField:
hint_text: "Enter Password"
icon_right:"lock"
pos_hint:{'center_x':0.5,'center_y':0.3}
size_hint_x:None
width:300
password: True
MDTextField:
hint_text: "Confirm Password"
icon_right:"lock"
pos_hint:{'center_x':0.5,'center_y':0.2}
size_hint_x:None
width:300
password: True
MDRaisedButton:
text:"Valider"
font_style:"H4"
type: 'bottom'
pos_hint: {'center_x':0.5,'center_y':0.08}
size_hint_x: 0.5
MDRectangleFlatButton:
text: ' re'
icon:"keyboard-return"
pos_hint: {'center_x':0.1,'center_y':0.9}
on_press: root.manager.current = 'menu'
type : 'Detour'
<LoginScreen>:
name: 'Login'
MDLabel:
text: "Login"
pos_hint: {"center_y": .85}
font_style:"H4"
halign : "center"
theme_text_color : "Custom"
MDTextField:
hint_text: "Username"
icon_right:"account"
pos_hint:{'center_x':0.5,'center_y':0.7}
size_hint_x:None
width:300
MDTextField:
hint_text: "Password"
icon_right : "lock"
pos_hint:{'center_x':0.5,'center_y':0.6}
size_hint_x:None
width:300
password : True
MDRaisedButton:
text:"Log in"
pos_hint: {'center_x':0.5,'center_y':0.4}
size_hint_x: 0.5
MDRectangleFlatButton:
text: 'Back'
pos_hint: {'center_x':0.9,'center_y':0.1}
on_press: root.manager.current = 'menu'
"""
class MenuScreen(Screen):
pass
class InscriptionScreen(Screen):
pass
class LoginScreen(Screen):
pass
# Create the screen manager
sm = ScreenManager()
sm.add_widget(MenuScreen(name="menu"))
sm.add_widget(InscriptionScreen(name="Inscription"))
sm.add_widget(LoginScreen(name="Login"))
class DemoApp(MDApp):
def build(self):
screen = Builder.load_string(Screen_helper)
return screen
DemoApp().run()
控制台反复报此错误,但弹出窗口就好了:
[CRITICAL ] [Clock ] 警告,在下一帧之前完成了太多迭代。检查你的代码,或者增加 Clock.max_iteration 属性
【问题讨论】: