Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python kivymd中单击“不更改屏幕”按钮_Python_Kivy_Python 3.7_Kivy Language - Fatal编程技术网

Python kivymd中单击“不更改屏幕”按钮

Python kivymd中单击“不更改屏幕”按钮,python,kivy,python-3.7,kivy-language,Python,Kivy,Python 3.7,Kivy Language,我是kivy的新手,不明白为什么导航抽屉中的按钮没有切换到kivymd中的另一个类 类ContentNavigationDrawer中有一个单击按钮,我希望它切换到另一个屏幕 我不明白为什么它没有改变,我已经阅读了关于ScreenManager的文档,但仍然无法理解 这是我的密码 main.py 这是我的主.kv文件 Screen: AboutUs: MainScreen: NavigationLayout: ScreenManager:

我是kivy的新手,不明白为什么导航抽屉中的按钮没有切换到kivymd中的另一个类 类ContentNavigationDrawer中有一个单击按钮,我希望它切换到另一个屏幕 我不明白为什么它没有改变,我已经阅读了关于ScreenManager的文档,但仍然无法理解

这是我的密码 main.py

这是我的主.kv文件

Screen:
    AboutUs:

    MainScreen:

    NavigationLayout:

        ScreenManager:

            Screen:

                BoxLayout:
                    orientation: 'vertical'

                    MDToolbar:
                        title: "Quote"
                        anchor_title: 'left'
                        elevation: 10
                        left_action_items: [['menu', lambda x: nav_drawer.set_state()]]
                        mode: "free-center"

                    Widget:



        MDNavigationDrawer:
            title: 'Quote'
            id: nav_drawer
            swipe_distance: 10

            ContentNavigationDrawer:
                id: content_drawer


<ContentNavigationDrawer>
    name: 'main'
    background_color: 2, 3, 4, 5
    orientation: "vertical"
    padding: "8dp"
    spacing: "8dp"

    AnchorLayout:
        anchor_x: "right"
        size_hint_y: None
        height: avatar.height

        Image:
            id: avatar
            size_hint: None, None
            size: "56dp", "56dp"
            source: "data/logo/kivy-icon-256.png"

        MDLabel:
            anchor_y: 'left'
            text: "[b]Story A Day[/b]"
            theme_text_color: "Custom"
            text_color: 0, 0, 0, 1
            markup: True
            font_style: "H4"
            size_hint_y: None
            height: self.texture_size[1]

    MDRaisedButton:
        md_bg_color: 0, 0, 0, 1
        text: 'You Can'
        on_release: root.hllo()

    MDRaisedButton:
        text: 'Click Me'
        on_release: print('Hell')

    MDLabel:
        text: 'Story A Day' 
        font_style: "Button"
        size_hint_y: None
        height: self.texture_size[1]

    OneLineAvatarListItem:
        text: "About Us"

        IconLeftWidget:
            icon: "information"

    Button:
        text: 'hello'
        on_release: app.root.manager.current = 'Abt'


    ScrollView:


<MainScreen>:
    canvas:
        Color:
            rgba: 0, 0, 0, 1 
        Rectangle:
            pos: self.pos
            size: self.size

    Label:
        id: quote
        text: root.quote_text
        font_size: '20sp'
        size: self.texture_size
        pos_hint: {'x': -0.2, 'y': 0.27}


<AboutUs>:
    name: 'Abt'
    Label:
        text: 'Hellooo'
屏幕:
关于:
主屏幕:
导航布局:
屏幕管理器:
屏幕:
盒子布局:
方向:“垂直”
MDToolbar:
标题:“报价”
主播标题:“左”
标高:10
左侧操作项:[['菜单],lambda x:nav_抽屉。设置状态()
模式:“自由中心”
小装置:
MDNavigationDrawer:
标题:“报价”
id:nav_抽屉
滑动距离:10
ContentNavigationDrawer:
id:content\u抽屉
名称:'main'
背景颜色:2,3,4,5
方向:“垂直”
填充:“8dp”
间距:“8dp”
主持人安排:
主持人:对
尺寸提示:无
高度:化身高度
图片:
id:avatar
大小提示:无,无
尺寸:“56dp”,“56dp”
资料来源:“data/logo/kivy-icon-256.png”
MDLabel:
主播:左
课文:“[b]一天的故事[/b]”
主题\文本\颜色:“自定义”
文本颜色:0,0,0,1
标记:正确
字体样式:“H4”
尺寸提示:无
高度:自身纹理大小[1]
MDRaisedButton:
md_背景_颜色:0,0,0,1
文字:“你不能
发布时:root.hllo()
MDRaisedButton:
文本:“单击我”
发布时:打印(“地狱”)
MDLabel:
文字:“一天的故事”
字体样式:“按钮”
尺寸提示:无
高度:自身纹理大小[1]
OneLinearListItem:
文字:“关于我们”
IconLeftWidget:
图标:“信息”
按钮:
短信:“你好”
发布时:app.root.manager.current='Abt'
滚动视图:
:
画布:
颜色:
rgba:0,0,0,1
矩形:
pos:self.pos
大小:self.size
标签:
id:报价
text:root.quote\u text
字体大小:“20sp”
大小:self.texture\u大小
位置提示:{'x':-0.2,'y':0.27}
:
名称:“Abt”
标签:
文字:“你好”

您必须将ScreenManager作为规则小部件,并将主屏幕放在第一个位置,最后将AboutUs类放在最后一个位置。

首先将所有屏幕放在ScreenManager中。因此,screenmanager可以控制更改屏幕

Screen:
    AboutUs:

    MainScreen:

    NavigationLayout:

        ScreenManager:

            Screen:

                BoxLayout:
                    orientation: 'vertical'

                    MDToolbar:
                        title: "Quote"
                        anchor_title: 'left'
                        elevation: 10
                        left_action_items: [['menu', lambda x: nav_drawer.set_state()]]
                        mode: "free-center"

                    Widget:



        MDNavigationDrawer:
            title: 'Quote'
            id: nav_drawer
            swipe_distance: 10

            ContentNavigationDrawer:
                id: content_drawer


<ContentNavigationDrawer>
    name: 'main'
    background_color: 2, 3, 4, 5
    orientation: "vertical"
    padding: "8dp"
    spacing: "8dp"

    AnchorLayout:
        anchor_x: "right"
        size_hint_y: None
        height: avatar.height

        Image:
            id: avatar
            size_hint: None, None
            size: "56dp", "56dp"
            source: "data/logo/kivy-icon-256.png"

        MDLabel:
            anchor_y: 'left'
            text: "[b]Story A Day[/b]"
            theme_text_color: "Custom"
            text_color: 0, 0, 0, 1
            markup: True
            font_style: "H4"
            size_hint_y: None
            height: self.texture_size[1]

    MDRaisedButton:
        md_bg_color: 0, 0, 0, 1
        text: 'You Can'
        on_release: root.hllo()

    MDRaisedButton:
        text: 'Click Me'
        on_release: print('Hell')

    MDLabel:
        text: 'Story A Day' 
        font_style: "Button"
        size_hint_y: None
        height: self.texture_size[1]

    OneLineAvatarListItem:
        text: "About Us"

        IconLeftWidget:
            icon: "information"

    Button:
        text: 'hello'
        on_release: app.root.manager.current = 'Abt'


    ScrollView:


<MainScreen>:
    canvas:
        Color:
            rgba: 0, 0, 0, 1 
        Rectangle:
            pos: self.pos
            size: self.size

    Label:
        id: quote
        text: root.quote_text
        font_size: '20sp'
        size: self.texture_size
        pos_hint: {'x': -0.2, 'y': 0.27}


<AboutUs>:
    name: 'Abt'
    Label:
        text: 'Hellooo'