比如这里是我的代码:
from kivy.properties import ObjectProperty
from kivymd.uix.button import MDFlatButton
from kivymd.uix.picker import MDDatePicker
from kivymd.app import MDApp
from kivy.lang import Builder
from kivymd.uix.dialog import MDDialog
from kivy.core.window import Window
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.config import Config
Config.set('kivy', 'keyboard_mode', 'systemandmulti')
Window.size = (400, 600)
class Log_in(Screen, MDApp):
def dop(self):
username = self.ids["user"].text
password = self.ids["passw"].text
if username == "MD" and password == "kivy":
self.manager.current = "main"
else:
dial = MDDialog(text='Opps Wrong!', background_color=(0.3, 1, 1, 0.3), size_hint=(0.5, 0.5),
radius=[20, 7, 20, 7], buttons=[
MDFlatButton(
text="Ok", text_color=self.theme_cls.primary_color, on_release=lambda x: dial.dismiss()
), ], )
dial.open()
class Main(Screen, MDApp):
date_y = ObjectProperty()
def date_se(self):
y = self.date_y
try:
MDDatePicker(self.today_date, y.year, y.month, y.day).open()
except AttributeError:
MDDatePicker(self.today_date).open()
def today_date(self, date_obj):
self.today_date = date_obj
如您所见,有 2 的屏幕。
class WindowManager(ScreenManager):
pass
kv = Builder.load_file("Wolf.kv")
class Wolf(MDApp):
def build(self):
self.theme_cls.primary_palette = "Yellow"
self.theme_cls.primary_hue = "900"
self.theme_cls.theme_style = "Dark"
return kv
Wolf().run()
这是我的 kivy 文件(kv):
WindowManager:
Log_in:
Main:
<Log_in>:
name:"log"
FloatLayout:
orientation:"vertical"
canvas.before:
Color:
rgba:rgba('#f2991b')
Triangle:
points:[0,self.size[1],self.size[0],self.size[1],0,self.size[1]-(0.4 *self.size[1])]
Color:
rgba:rgba('#f2881b')
Triangle:
points:[0,self.size[1],self.size[0],self.size[1],self.size[0],self.size[1]-(0.4 *self.size[1])]
MDIconButton:
text:'Nxt'
icon:"account"
size_hint:0.15,0.15
pos_hint:{'x':0.43,'y':0.55}
MDTextField:
id: user
hint_text : "Enter your Name"
helper_text : "Have u forget it?"
helper_text_mode : "on_focus"
icon_right : "android"
size_hint_x :None
width : '300'
pos_hint:{'center_x':0.5,'center_y':0.5}
multiline : False
foreground_color:0,0,1,1
on_text_validate: app.on_text_validate_callback(self)
MDTextField:
id: passw
hint_text : "Enter your Password"
helper_text : "cAsE SeNsItIvE"
helper_text_mode : "on_focus"
icon_right : "key"
size_hint_x :None
width : '300'
pos_hint:{'center_x':0.5,'center_y':0.4}
multiline : False
password:True
MDRectangleFlatButton:
id:btn
text:"Log in"
pos_hint:{'center_x': 0.5, 'center_y': 0.3}
on_press:root.dop()
<Main>:
name:"main"
FloatLayout:
MDIconButton:
icon:"alarm"
text:"Hlo"
on_press:root.date_se()
size_hint:0.15,0.15
pos_hint:{'x':0.03,'y':0.8}
现在我面临的问题是,我希望 21 天后用户名应该自动更改为“RIOT”,密码自动更改为“zxcvbnm”。正如大多数防病毒软件中发生的那样,在某些日子后他们会要求提供许可证密钥。我只想免费试用我的应用程序 21 天。我认为时钟功能将与 if 语句一起使用,但如何使用?谢谢帮助:)