[英]Login Screen kivy/kivymd
I am creating an app using python (kivy and kivymd) and I have a login screen but every time I open my application I will get this screen,how can I make to appear once and disappear permanently?我正在使用 python(kivy 和 kivymd)创建一个应用程序,我有一个登录屏幕,但每次我打开我的应用程序时,我都会看到这个屏幕,我怎样才能让出现一次并永久消失?
Use a config file to store the information to decide whether to open the login screen.使用配置文件来存储信息来决定是否打开登录屏幕。
The following code will help:以下代码将有所帮助:
It tries to read a 'temp.txt' file它尝试读取“temp.txt”文件
On first run, there is no such file and an exception will be thrown calling the except block第一次运行时,没有这样的文件,将抛出调用 except 块的异常
Code:代码:
global k
try:
with open('temp.txt','r') as file:
p = file.read()
global k
k = False
except:
global k
with open('temp.txt','w') as file:
file.write('1')
k = True
class Management(ScreenManager):
def __init__(self,*kwargs):
global k
if k:
self.current = 'LoginScreen'
else:
self.current = 'HomeScreen'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.