你好,
我实际上想要做的是以下几点:
我想创建这个登录屏幕,如果你有正确的邮件(在这种情况下只有 test@test.com)来从 KV 文件触发 inapp 屏幕,这是我的实际问题。
我无法触发“inapp”屏幕
我在 PY 文件中没有我的 screenmanager 和我的屏幕类的原因是因为它被窃听了,当我切换屏幕时它重叠 这是一个有问题的 UI 的示例
在我的情况下我做错了什么?
这是我的PY 文件:
class mytest(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark"
self.theme_cls.accent_palette = 'Blue'
self.theme_cls.accent_hue = '300'
self.theme_cls.primary_palette = "Green"
self.theme_cls.primary_hue = "400"
self.icon = 'testphoto.png'
self.title = "coolapp"
def login_checker(self, mail, psswrd):
hismail = mail
hispass = psswrd
print(themail)
print(thepass)
access_screen = self.root.ids.inapp
if themail == "test@test.com":
print("Corect")
access_screen
else:
toast("Invalid E-mail")
这是KV 文件:
BoxLayout:
ScreenManager:
id: scrin_meneger
Screen: #LOGIN
name: "login"
id: loginn
FloatLayout:
orientation: 'vertical'
Image: #Login Background Image
source: "./pictures/whitebg.jpg"
allow_stretch: True
keep_ratio: False
MDTextField: #mail-input
id: emadress
pos_hint: {'center_x': .5, 'center_y': .6}
size_hint: 0.60, 0.06
hint_text: "Email: "
current_hint_text_size: 0.5, 1
current_hint_text_color: 0, 0, 0, .60
helper_text: "No input provided"
helper_text_mode: "on_error"
color_mode: 'custom'
line_color_focus: 0, 0, 0, 1
required: True
max_text_lenght: 20
#min_text_lenght: 5
MDTextField: #pass-input
id: psswd
pos_hint: {'center_x': .5, 'center_y': .5}
size_hint: 0.60, 0.06
password: True
hint_text: "Password: "
current_hint_text_color: 0, 0, 0, .60
helper_text: "No input provided"
helper_text_mode: "on_error"
color_mode: 'custom'
line_color_focus: 0, 0, 0, 1
required: True
max_text_lenght: 20
#min_text_lenght: 5
MDFlatButton: #Login Button
text: "Login"
text_color: 0, 0, 0, .80
pos_hint: {'center_x': .3, 'y': .2}
size_hint: 0.4, 0.1
on_release:
app.login_checker(emadress.text, psswd.text)
Screen: #Application
name: 'inapp'
id: inapp
BoxLayout:
orientation: 'vertical'
MDBottomNavigation:
#Screen 1
MDBottomNavigationItem:
id: main_screen
name: "main_menu"
text: "Main Menu"
icon: "air-humidifier"
BoxLayout:
orientation: 'vertical'
MDToolbar:
id: toolbar
title: "This is my MDToooolbar"