Reputation: 111
I can only import one image into kivy but if i tried to import more than one it gets an error saying, "Only one root object is allowed by .kv"
main.py
import kivy
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.lang import Builder
lol = Builder.load_file("my.kv")
class Myapp(App):
def build(self):
return lol
if __name__== "__main__":
Myapp().run()
my.kv
Image:
source: 'equalizer.gif'
size_hint: 0.3, 0.4
pos_hint: {'center_x': 0.5, 'center_y': 0.5}
Image:
source: 'themp.png'
pos_hint: {'left': 1, 'top': 1}
size_hint: None, None
Upvotes: 1
Views: 936
Reputation: 244033
As the message kivy only allows to have a root since kivy only supports one window, so if you want to show several items then you must use a container, for example a BoxLayout:
BoxLayout:
orientation: "vertical"
Image:
source: 'equalizer.gif'
size_hint: 0.3, 0.4
pos_hint: {'center_x': 0.5, 'center_y': 0.5}
Image:
source: 'themp.png'
pos_hint: {'left': 1, 'top': 1}
size_hint: None, None
Upvotes: 2