首页 > 解决方案 > Find an object in a library (here, it is the NavigationLayout of the Kivy library)

问题描述

I am learning Kivy and I'm not used to .kv, so I am trying to learn the "hard way" first.

Problem: there is not a lot of documentation for interaction with Kivy except .kv.

I'm stuck with the import of the NavigationLayout, I tried to find it on the official Github, but I failed !

from kivy.uix.boxlayout import BoxLayout
from kivymd.uix.toolbar import MDToolbar
from kivy.properties import ObjectProperty
from kivy.uix.screenmanager import ScreenManager, Screen
from kivymd.app import MDApp
#from kivy import road.to.navigationlayout import NavigationLayout


class App(MDApp):
    def build(self):
        screen_manager = ScreenManager()
        main_screen = Screen()
        main_box = BoxLayout()
        main_toolbar = MDToolbar()
        main_toolbar.title = "Hello there !"
        #navigation_layout = NavigationLayout()

        screen_manager.add_widget(main_screen)
        main_screen.add_widget(main_box)
        main_box.add_widget(main_toolbar)
        return screen_manager


App().run()

PS: If you have tips to find out where objects are situated in new libraries, I would be happy to heard them!

标签: pythonkivy

解决方案


它在 MDKivy 库中。(我在另一个堆栈溢出帖子中找到了它)

from kivymd.uix.navigationdrawer import NavigationLayout


推荐阅读