进入的第一个屏幕是登录屏幕,但是我可以绕过登录屏幕单击操作栏上的任何按钮。我什至想到要删除操作栏按钮,然后如果登录成功就可以将它们放回去,但是我不知道如何从登录屏幕类调用操作栏的ID。阻止用户绕过应用程序登录屏幕的最佳方法是什么?Python代码:from kivy.uix.behaviors import ButtonBehaviorfrom kivy.uix.image import Imagefrom kivy.app import Appfrom kivy.uix.screenmanager import ScreenManager, Screenfrom kivy.properties import ObjectPropertyfrom kivy.uix.boxlayout import BoxLayoutfrom kivy.lang import Builderfrom kivy.clock import mainthreadfrom kivy.uix.button import Buttonfrom kivy.uix.popup import Popupfrom kivy.uix.label import Labelfrom kivy.uix.button import Buttonfrom kivy.uix.scrollview import ScrollViewBuilder.load_file('main.kv')class Menu(BoxLayout): manager = ObjectProperty(None)class ScreenLogIn(Screen): @mainthread def verify_credentials(self): try: if self.ids.login.text == "email@email.com" and self.ids.passw.text == "password": self.manager.current = "match" else: popup = Popup(title='Try again', content=Label(text='Wrong Email/Password'), size_hint=(None, None), size=(400, 400), auto_dismiss=True) popup.open() except Exception as e: passclass ScreenNearUsers(Screen): @mainthread def on_enter(self): for i in xrange(101): button = Button(text="B_" + str(i)) self.ids.grid.add_widget(button)class ScreenMatch(Screen): passclass ScreenChats(Screen): passclass ScreenUserProfile(Screen): passclass Manager(ScreenManager): screen_log_in = ObjectProperty(None) screen_near_user = ObjectProperty(None) screen_match = ObjectProperty(None) screen_chats = ObjectProperty(None) screen_user_profile = ObjectProperty(None)class MenuApp(App): def build(self): return Menu()if __name__ == '__main__': MenuApp().run()
添加回答
举报
0/150
提交
取消