在Kivy中添加导航抽屉后,背景图片将不会显示

时间:2019-05-09 16:27:40

标签: python kivy

所以我一直在创建一个应用程序,我想要一个导航抽屉,所以我添加了一个。但是,似乎我是皇家菜鸟,以某种方式使我的屏幕背景消失了。我试着用canvas.after弄乱了,它似乎可以工作,但是它显示在屏幕文本和按钮的前面。我对python和Kivy非常陌生,因此请对您的回答保持温和!

FloatLayout:
    canvas:
        Rectangle:
            pos: self.pos
            size: self.size
            source: '9.png'


    NavigationDrawer:
        FloatLayout:
            orientation: 'vertical'
            canvas.before:
                Rectangle:
                    pos: self.pos
                    size: self.size
                    source: '9.png'
            Label:
                text: "Navigation Menu"
                pos_hint: {"y": 0.75}
                size_hint: 1, 0.2
                font_size: (root.width**2 + root.height**2) / 14**4
                font_name: "Product Sans.ttf"

            Button:
                text: "Example button"
                pos_hint: {"y":0.66}
                size_hint: 1.1, 0.06
                font_name: "OpenSans.ttf"
                on_release:
                    app.root.current = "Example"
                    root.manager.transition.direction = "right"

            Button:
                text: "Example button 2"
                pos_hint: {"y":0.1}
                size_hint: 1, 0.06
                font_name: "OpenSans.ttf"
                on_release:
                    app.root.current = "Example"
                    root.manager.transition.direction = "right"

        FloatLayout:
            size: root.width, root.height/2
            cols:2
            canvas:
                Rectangle:
                    pos: self.pos
                    size: self.size
                    source: '9.png' 
            Label:
                bold: True
                font_name: 'Product Sans.ttf'
                size_hint: 0.8,0.3
                pos_hint: {"x":0.1, "y":0.75}
                text: "Example"
                font_size: (root.width**2 + root.height**2) / 12**4

            Label:
                font_name: 'OpenSans.ttf'
                size_hint: 0.5,0.12
                pos_hint: {"x":0.08, "top":0.6}
                text: "Example "
                font_size: (root.width**2 + root.height**2) / 14**4

            TextInput:
                pos_hint: {"x":0.5, "top":0.58}
                size_hint: 0.4, 0.08
                id:Example
                multiline:False
                font_size: (root.width**2 + root.height**2) / 14**4

            RippleButton:
                font_name: 'OpenSans.ttf'
                text:"Exampler"
                pos_hint:{"x":0.3,"y":0.20}
                size_hint: 0.4, 0.1
                font_size: (root.width**2 + root.height**2) / 14**4
                on_release:
                    root.folder()

            RippleButton:
                text:"Example"
                font_name: 'OpenSans.ttf'
                pos_hint:{"x":0.3,"y":0.08}
                size_hint: 0.4, 0.1
                font_size: (root.width**2 + root.height**2) / 14**4
                on_release:
                    root.chrome()

            FloatButton:
                id: float_root
                size_hint: (None,None)
                btn_size: (50,50)
                size: (50,50)
                bg_color: (255,255,255,1)
                pos_hint: {'x': 0.01}
                RippleButton: 
                    text: float_root.text
                    markup: True
                    size_hint: (None,None)
                    size: float_root.btn_size
                    pos_hint: {'x': 0.05, 'y': 0.15}
                    background_normal: ''
                    background_color: (0,0,0,0)
                    canvas.before:
                        Ellipse:
                            size: self.size
                            pos: self.pos
                            source: 'LACB.png'
                    on_release:
                        app.root.current = "main"
                        root.manager.transition.direction = "right"

因此,当我运行此命令时,我的背景图像消失了,背景现在变成了黑色。任何帮助将不胜感激!

0 个答案:

没有答案