在一个程序错误中使用两个kv文件

时间:2016-08-16 16:19:58

标签: python-3.x oop kivy python-3.4 kivy-language

我对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代码,请问)

0 个答案:

没有答案