我对 OOP 很陌生,我目前正在尝试使用 kivy 创建我的第一个项目。该程序目前卡在我登录时我尝试打开一个新的 kv 文件,但它不会打开。这是python代码:
window_widget = Builder.load_file("LiveScoringV104KVLoggedIn.kv")
class LoginScreen(Screen):
def checkLogin(self, username, password):
usernamesFile = open("dataUsernamesV104.txt", "r")
passwordsFile = open("dataPasswordsV104.txt", "r")
for line in usernamesFile.readlines():
for lineb in passwordsFile.readlines():
with open("dataprintedUsernameV104.txt", "w") as printedUsername:
printedUsername.write(username + "\n")
if line == username and lineb == password:
print("This is working")
return window_widget
else:
print("All wrong")
root_widget = Builder.load_file("LiveScoringV104KV.kv")
class StartupHome(App):
def build(self):
return root_widget
if __name__ == "__main__":
StartupHome().run()
当我登录时,这是正确的,因为它正在打印,window_widget 没有被调用,因为它不运行 kv 文件,但是 root_widget 被调用。我怎样才能让 kv 文件像 root_widget 一样运行?(如果您需要 kv 代码,请询问)