python-3.xdrop-down-menukivy-languagekivymd

MDDropdownmenu does not appear in KivyMD


I have updated KivyMD to version 2.0.1dev0. I have a main.py through which the program is launched:

screen_list = '''
ScreenManager:
    id: sm
    
    LoginPage:
        id: login_page
        name: 'login_page'        
'''


class LiferApp(MDApp):
    def build(self):
        App.title = "LiferApp"
        Window.size = (393, 851)
        return Builder.load_string(screen_list)


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

There is a code for the login_page.kv page:

<LoginPage>

    FloatLayout:
        adaptive_size: True
        canvas:
            Color:
                rgba: 255/255, 255/255, 255/255, 1
            Rectangle:
                size: self.size
                pos: self.pos


        MDIconButton:
            id: cfg
            style: 'standard'
            icon: 'cog'
            theme_icon_color: "Custom"
            pos_hint: {'center_x': .9, 'center_y': .95}
            on_release: root.config_button_click()

        Widget:
            id: button_back
            size_hint: .35, .04
            pos_hint: {'center_x': .3, 'center_y': .7}
            md_bg_color: 'blue'
            opacity: .5
            canvas:
                Color:
                    rgba: 10/255, 67/255, 126/255, 1
                RoundedRectangle:
                    pos: self.pos
                    size: self.size

py.file contains the following code:

Builder.load_file('kv/login_page.kv')


class LoginPage(Screen):

    def config_button_click(self):
        menu_items = [
            {'text': 'About', 'on_release': lambda x='1': self.about_open()},
            {'text': 'Tech', 'on_release': lambda x='2': self.tech_page_open()},
            {'text': 'Contacts', 'on_release': lambda x='3': self.contacts_page_open()},
        ]

        self.cfg_menu = MDDropdownMenu(caller=self.ids.cfg, items=menu_items)
        self.cfg_menu.open()

The problem is that when you click on the MDIconButton, the application closes with the following error:

ValueError: MDDivider.md_bg_color accept only str

enter image description here

However, if you add a viewclass to menu_items, for example MDListItem, it opens, but no text is displayed (adding a text color change does not help). What could be the problem?

KivyMD: 2.0.1dev0 Python: 3.9


Solution

  • The problem was in login_page.kv:

    Widget:
        id: button_back
        size_hint: .35, .04
        pos_hint: {'center_x': .3, 'center_y': .7}
        md_bg_color: 'blue'
        opacity: .5
        canvas:
            Color:
                rgba: 10/255, 67/255, 126/255, 1
            RoundedRectangle:
                pos: self.pos
                size: self.size
    

    I've delete md_bg_color: 'blue' and it starts to work