KivyMD MDNavigationDrawer showing under other widgets

1,167 views
Skip to first unread message

jonthecomposer

unread,
Dec 1, 2017, 11:50:16 PM12/1/17
to Kivy users support
I need help, please.

I have written a typical Kivy app utilizing the newest KivyMD and, although I am getting functionality, the drawer is appearing under the other widgets. I know it has SOMETHING to do with how I am coding it, but I simply cannot figure it out as I've spent a couple of days on it. 

I don't believe it's a bug, installation, or dependency issue since I can use kivy just fine, and when I run Kitchen Sink, everything works as normal. With that being said, I modeled my app's kv loosely after Kitchen Sink's layout (not the widget, but the coding). 

It's what I call an "idiot app" that only tests the logic, layout, or functionality of something as a proof-of-concept. So it's simple and makes no sense except for that.

Thanks in advance.

Here is my py code:

# -*- coding: utf-8 -*-
from kivy.app import App
from kivymd.label import MDLabel
from kivymd.toolbar import Toolbar
from kivymd.theming import ThemeManager
from kivymd.button import MDRaisedButton
from kivy.uix.boxlayout import BoxLayout
from kivymd.navigationdrawer import NavigationLayout
from kivymd.navigationdrawer import MDNavigationDrawer

class RootWidget(NavigationLayout):
   pass

class MainApp(App):
   theme_cls = ThemeManager()

    def build(self):
       return RootWidget()
   
if '__main__' == __name__:
   MainApp().run()

Here is my kv code:


<RootWidget>:
    id:mdnl
    MDNavigationDrawer:
        id:mdnd
        NavigationDrawerToolbar:
            title: "Navigation Drawer"
        NavigationDrawerIconButton:
            icon: 'checkbox-blank-circle'
            text: "   you"
            
            on_release: app.root.ids.lbl.text = self.text
        NavigationDrawerIconButton:
            icon: 'checkbox-blank-circle'
            text: "   me"
            
            on_release: app.root.ids.lbl.text = self.text
        NavigationDrawerIconButton:
            icon: 'checkbox-blank-circle'
            text: "   them"
            
            on_release: app.root.ids.lbl.text = self.text
        NavigationDrawerIconButton:
            icon: 'checkbox-blank-circle'
            text: "   us"
            
            on_release: app.root.ids.lbl.text = self.text
        NavigationDrawerIconButton:
            icon: 'checkbox-blank-circle'
            text: "go to screen 2"
            
            on_press: app.root.ids.sm.current = 's2'
        NavigationDrawerIconButton:
            icon: 'checkbox-blank-circle'
            text: "go to screen 1"
            
            on_press: app.root.ids.sm.current = 's1'
    BoxLayout:
        orientation: 'vertical'
        Toolbar:
            id: toolbar
            size_hint: 1, .2
            title: 'Welcome'
            left_action_items: [['menu', lambda x: app.root.toggle_nav_drawer()]]
        ScreenManager:
            id:sm
            size_hint: 1, .8
            Screen:
                name: 's1'
                MDLabel:
                    theme_text_color: 'Secondary'
                    halign: 'center'
                    text: '   screen 1'
            Screen:
                name: 's2'
                MDLabel:
                    theme_text_color: 'Secondary'
                    halign: 'left'
                    text: '   screen 2'
                MDRaisedButton:
                    text: 'open/close'
                    elevation_normal: 2
                    opposite_colors: True
                    size_hint: 1, .25
                    on_press: app.root.toggle_nav_drawer()
                MDLabel:
                    halign: 'left'
                    size_hint: 1, .25
                    id:lbl



This is the program with the drawer closed: 


This is with the drawer open:

This is my output:


ZenCODE

unread,
Dec 3, 2017, 2:22:54 PM12/3/17
to Kivy users support
Have you tried moving it so it's the last widget (in RootWidget )and not the first?

jonthecomposer .

unread,
Dec 7, 2017, 4:26:59 AM12/7/17
to kivy-...@googlegroups.com
Yes, but it didn't work. All I got was a white, blank, window. 

On Sun, Dec 3, 2017 at 1:22 PM, ZenCODE <zenkey....@gmail.com> wrote:
Have you tried moving it so it's the last widget (in RootWidget )and not the first?

--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/-R9VICxF7pk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

werton

unread,
Dec 8, 2017, 10:34:21 AM12/8/17
to Kivy users support
# -*- coding: utf-8 -*-
from kivy.app import App
from kivymd.label import MDLabel
from kivymd.toolbar import Toolbar
from kivymd.theming import ThemeManager
from kivymd.button import MDRaisedButton
from kivy.uix.boxlayout import BoxLayout
from kivymd.navigationdrawer import NavigationLayout
from kivymd.navigationdrawer import MDNavigationDrawer
from kivy.lang import Builder

# class RootWidget(NavigationLayout):
#    pass


class MainApp(App):
    theme_cls
= ThemeManager()

   
def build(self):

        main_widget
= Builder.load_file("MainApp.kv")
       
return main_widget

if '__main__' == __name__:
   
MainApp().run()

NavigationLayout:


четверг, 7 декабря 2017 г., 18:26:59 UTC+9 пользователь jonthecomposer написал:
Yes, but it didn't work. All I got was a white, blank, window. 
On Sun, Dec 3, 2017 at 1:22 PM, ZenCODE <zenkey....@gmail.com> wrote:
Have you tried moving it so it's the last widget (in RootWidget )and not the first?

--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/-R9VICxF7pk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.

jonthecomposer .

unread,
Dec 14, 2017, 7:05:12 PM12/14/17
to kivy-...@googlegroups.com
That's weird. It was my idea that calling something RootWidget and giving it its own class would do the same thing. What concept am I missing here? It seems both are top level and inherit exactly the same things. 

To unsubscribe from this group and all its topics, send an email to kivy-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages