猿问

在登录Kivy之前如何防止用户越过App的登录屏幕

进入的第一个屏幕是登录屏幕,但是我可以绕过登录屏幕单击操作栏上的任何按钮。我什至想到要删除操作栏按钮,然后如果登录成功就可以将它们放回去,但是我不知道如何从登录屏幕类调用操作栏的ID。阻止用户绕过应用程序登录屏幕的最佳方法是什么?


Python代码:


from kivy.uix.behaviors import ButtonBehavior

from kivy.uix.image import Image

from kivy.app import App

from kivy.uix.screenmanager import ScreenManager, Screen

from kivy.properties import ObjectProperty

from kivy.uix.boxlayout import BoxLayout

from kivy.lang import Builder

from kivy.clock import mainthread

from kivy.uix.button import Button

from kivy.uix.popup import Popup

from kivy.uix.label import Label

from kivy.uix.button import Button

from kivy.uix.scrollview import ScrollView



Builder.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:

        pass



class 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):

    pass



class ScreenChats(Screen):

    pass



class ScreenUserProfile(Screen):

    pass



class 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()



收到一只叮咚
浏览 146回答 1
1回答
随时随地看视频慕课网APP

相关分类

Python
我要回答