Reputation: 51
I am able to run the program but when it loads the kivy window is blank. I keep receiving a warning that the kivy is loaded multiple times. Thank you in advance.
[WARNING] [Lang ] The file C:\Users\Eli\PycharmProjects\MedBay\mymain.kv is loaded multiples times, you might have unwanted behaviors.
main.py
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
class WindowManager(ScreenManager):
pass
class MainWindow(Screen):
pass
class SecondWindow(Screen):
pass
kv = Builder.load_file("mymain.kv")
class MyMainApp(App):
def build(self):
return kv
if __name__ =="__main__":
MyMainApp().run()
kv file (named mymain.kv)
WindowManager:
MainWindow:
SecondWindow:
<MainManager>:
name: "Main"
GridLayout:
cols: 1
GridLayout:
cols: 2
Label:
text: "password:"
TextInput:
id: passw
multiline: False
Button:
text: "Submit"
on_release:
app.root.current = "second"
<SecondWindow>:
name:"second"
Button:
text: "Go Back"
on_release:
app.root.current = "Main"
Upvotes: 0
Views: 417
Reputation: 29468
kv = Builder.load_file("mymain.kv")
class MyMainApp(App):
The App, when run, automatically loads a kv file with the same name as the app (omitting any trailing App
and converting to lowercase). Thus, your kv file is loaded twice.
See the documentation for more information.
Upvotes: 1