Only one root object is allowed by .kv

515 views
Skip to first unread message

Luigi Marongiu

unread,
May 24, 2020, 9:11:20 AM5/24/20
to Kivy users support
Hello,
I used to have a file where I instantiate a widget; I tried to remove it and use screens to handle different screens. But I got this error:
```
...
...
       5:    SleepOn:
       6:        name: "sleep_on"
 >>    7:sleep_on:
       8:    BoxLayout:
       9:        orientation: "vertical"
 ...
 Only one root object is allowed by .kv
```
I have defined three screens, of which one is the window manager (if it is compulsory, I am not sure). In the class `ClockApp`, which before was returning the widget, I returned now the kivy file:
```
class ClockApp(App):
    def build(self):
        return Builder.load_file("./clock.kv")
```
Even if I simply define build(self) as `pass`, I still get the error.
How can I define a single root?
bells.mp3
clock.kv
Clock.py
sleepy.jpg

Elliot Garbus

unread,
May 24, 2020, 11:05:05 AM5/24/20
to kivy-...@googlegroups.com

I’m assuming you wanted the code below.

I commented out the WakeCall Screen, there is nothing defined for it yet.

WindowManager is the root widget.  It is in the far left column.  <SleepOn> is a rule.

 

 

#:kivy 1.10.1
WindowManager:
#    WakeCall:
#        name: "wake_call"
   
SleepOn:
        name:
"sleep_on"

<SleepOn>:
   
BoxLayout:
       
orientation: "vertical"
       
size: root.width, root.height
        cols
: 1
       
GridLayout:
           
pos_hint: {'center_x':.5}
           
cols: 3
           
rows: 1
           
ImageButton:
               
size_hint_x: 1
               
size_hint_y: 0.8
               
source: "./sleepy.jpg"
               
on_release:
                    h_clock.cancel_time()
                   
self.source = './awake.jpg'
                   
h_clock.text = "BEEP"
       
clockLabel:
           
id: h_clock
           
size_hint_x: 1
           
size_hint_y: 0.2
           
font_size: 85
           
color: 0, 1, 1, 1
           
bold: True
           
text: self.current_time

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/bc215115-7a55-4bb9-aa3b-057af49faa2c%40googlegroups.com.

 

Luigi Marongiu

unread,
May 24, 2020, 2:50:56 PM5/24/20
to Kivy users support
Thank you!
> To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/5eca8d15.1c69fb81.2b55c.9e30SMTPIN_ADDED_MISSING%40gmr-mx.google.com.



--
Best regards,
Luigi
Reply all
Reply to author
Forward
0 new messages