微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

轮播和导航抽屉工具栏问题Kivymd + Python

如何解决轮播和导航抽屉工具栏问题Kivymd + Python

我想添加一个包含轮播小部件的屏幕(以幻灯片方式显示图像)。而且,我已经在我的脚本中添加一个导航工具栏和一个导航抽屉。虽然,我在屏幕 2 中添加了轮播,但它阻止我访问导航抽屉(导航工具栏顶部的 3 行)。请帮忙..

from kivy.lang import Builder
from kivy.core.window import Window
from kivy.uix.Boxlayout import BoxLayout
from kivy.properties import ObjectProperty
from kivymd.theming import ThemableBehavior
from kivymd.uix.list import MDList
from kivymd.app import MDApp
from kivymd.uix.expansionpanel import MDExpansionPanel,MDExpansionPanelThreeLine
from kivy.uix.popup import Popup
from kivy.uix.image import Image



Window.size = (300,500)
navigation_helper = """
<MyTile@SmartTileWithLabel>
    size_hint_y: None
    height: "240dp"
Screen:
    MDToolbar:
        id: toolbar
        pos_hint: {"top": 1}
        elevation: 10
        title: "Navigation ToolBar"
        left_action_items: [["menu",lambda x: nav_drawer.set_state("open")]]
        
    NavigationLayout:
        x: toolbar.height

        ScreenManager:
            id: screen_manager

            Screen:
                name: "Screen1"
                MDLabel:
                    text: "Screen1"
                    halign: "center"
                MDCard:
                    size_hint: None,None
                    size: "10dp","10dp"
                    pos_hint: {"center_x": .5,"center_y": .5}
                    on_press:
                        nav_drawer.set_state("close")
                        screen_manager.current = "Screen4"

                    
            Screen:
                name: "Screen5"     

            Screen:
                name: "Screen2"
                MDLabel:
                    text: "Screen2"
                    halign: "center"
                BoxLayout:
                    orientation: "vertical"
                    Screen: 
                        Carousel:
                            MDFloatLayout:
                                MDCard:
                                    size_hint: .5,.5
                                    pos_hint: {"center_x":0.2,"center_y":0.2}
                                    Image:
                                        source: "new.png"
                                    MDIconButton:
                                        icon:"facebook"
                                        icon:"google"
                            MDFloatLayout:
                                MDCard:
                                    size_hint: .5,.5
                                    pos_hint: {"center_x":0.5,"center_y":0.5}
                                    Image:
                                        source: "new1.png"
                                    MDIconButton:
                                        icon:"facebook"
                                        icon:"google"
                
            Screen:
                name: "Screen4"
                MDLabel:
                    text: "Screen4"
                    halign: "center"

        MDNavigationDrawer:
            id: nav_drawer

            ContentNavigationDrawer:
                screen_manager: screen_manager
                nav_drawer: nav_drawer
           
                ScrollView:
                    MDList:

                        OneLineListItem:
                            text: "Screen1"
                            on_press:
                                nav_drawer.set_state("close")
                                screen_manager.current = "Screen1"
            
                        OneLineListItem:
                            text: "Screen2"
                            on_press:
                                nav_drawer.set_state("close")
                                screen_manager.current = "Screen2"


"""

class DemoApp(MDApp):
    class ContentNavigationDrawer(BoxLayout):
        screen_manager = Objectproperty()
        nav_drawer = Objectproperty()

    # class DrawerList(ThemableBehavior,MDList):
    #     pass

    def build(self):
        screen = Builder.load_string(navigation_helper)
        return screen

    def on_start(self):
        pass

DemoApp().run()

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。