Reputation: 21
I have my python code:
from kivy.app import App
from kivy.uix.scatter import Scatter
from kivy.uix.label import Label
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.textinput import TextInput
from kivy.uix.boxlayout import BoxLayout
class Premade(BoxLayout):pass
class MyFirstApp(App):
def build(self):
return Premade()
if __name__ == '__main__':
MyFirstApp().run()
and my .kv
file:
#:kivy 1.10.0
<Premade>:
orientation: 'Verticle'
TextInput:
id: my_textinput
font_size: 150
size_hint_y: None
height: 200
text: 'default'
FloatLayout:
Scatter:
Label:
text: my_textinput.text
font_size: 150
Supposedly, when I run the python code, the .kv
file would be loaded, but all I get is a black screen. I named my .kv
file according to the rule, in this case, is myfirst.kv
and the .kv
file is also in the same directory as the python module file. I also tried to use the build
function but that didn't work either. Can anyone help?
Upvotes: 2
Views: 1284
Reputation: 5613
Check your .kv
filename, if you want it to be loaded automatically you should name it MyFirst.kv
because your app is called MyFirstApp
. An alternative solution would be to load the file manually as the following:
from kivy.lang import Builder
Builder.load_file('filename.kv')
Upvotes: 2