Kivy 更改 Z 索引

Kivy Change Z-index

我仍然在掌握 kivy 和 python 的窍门,所以请耐心等待。我有两个布局,我的图形布局覆盖了我的 TopBar 布局的属性。有什么办法可以解决这个问题吗?

这是我的 .kv 文件:

Root:
    orientation: "vertical"

    TopBar:
        size_hint: 1,0.08
        size_hint_max_y: 100
        pos_hint: {"top":1}

        TextInput:
            text: "Search"
            right: True
            size_hint_max_x: 200
        Button:
            text: str(self.state)
    Graph:
        size_hint_max_y: 100
        Button:
            text: "test"

这是 python 文件:

class Root(BoxLayout):
    def __init__(self, **kwargs):
        super(Root, self).__init__(**kwargs)


class TopBar(BoxLayout):
    pass

class Graph(FloatLayout):
    pass

class Gui(App):
    def build(self):
       return Root()

Gui().run()

谢谢!

kv 文件

size_hint_max_y: 100Graph: 下移动到 Button: 下。

在代码段中,添加了颜色以说明 图表 的 canvas。

片段

Graph:
    canvas.before:
        Color:
            rgba: 0, 0, 1, 0.5    # 50% blue
        Rectangle:
            pos: self.pos
            size: self.size

    Button:
        size_hint_max_y: 100
        text: "test"

输出