python3 kivy BoxLayout超过另一个

python3 kivy BoxLayout超过另一个,python,kivy,boxlayout,Python,Kivy,Boxlayout,我查看了文档,了解如何在我的kivy窗口中放置我的框布局 但我想将我的BoxLayout放置在另一个(透明背景)上,如下所示: 我的代码(不带我的五个透明红色框) 尝试将boxlayouts置于浮动布局中,如下所示: from kivy.app import App from kivy.lang import Builder KV = """ <MyButton@Button>: background_color: (1,0,0,.5) FloatLayout:

我查看了文档,了解如何在我的kivy窗口中放置我的框布局

但我想将我的BoxLayout放置在另一个(透明背景)上,如下所示:

我的代码(不带我的五个透明红色框)


尝试将boxlayouts置于浮动布局中,如下所示:

from kivy.app import App
from kivy.lang import Builder


KV = """

<MyButton@Button>:
    background_color: (1,0,0,.5)

FloatLayout:

    BoxLayout:
        Button:
            text: "test"
        Button:
            text: "test"

    BoxLayout:
        orientation: "vertical"
        MyButton:
            text: "test"
        MyButton:
            text: "test"

"""


class MyApp(App):

    def build(self):
        return Builder.load_string(KV)

MyApp().run()
从kivy.app导入应用
从kivy.lang导入生成器
KV=”“”
:
背景颜色:(1,0,0,5)
浮动布局:
盒子布局:
按钮:
文本:“测试”
按钮:
文本:“测试”
盒子布局:
方向:“垂直”
我的按钮:
文本:“测试”
我的按钮:
文本:“测试”
"""
类别MyApp(应用程序):
def生成(自):
返回生成器。加载字符串(KV)
MyApp().run()
输出:


尝试将boxlayouts放在floatlayout中,如下所示:

from kivy.app import App
from kivy.lang import Builder


KV = """

<MyButton@Button>:
    background_color: (1,0,0,.5)

FloatLayout:

    BoxLayout:
        Button:
            text: "test"
        Button:
            text: "test"

    BoxLayout:
        orientation: "vertical"
        MyButton:
            text: "test"
        MyButton:
            text: "test"

"""


class MyApp(App):

    def build(self):
        return Builder.load_string(KV)

MyApp().run()
从kivy.app导入应用
从kivy.lang导入生成器
KV=”“”
:
背景颜色:(1,0,0,5)
浮动布局:
盒子布局:
按钮:
文本:“测试”
按钮:
文本:“测试”
盒子布局:
方向:“垂直”
我的按钮:
文本:“测试”
我的按钮:
文本:“测试”
"""
类别MyApp(应用程序):
def生成(自):
返回生成器。加载字符串(KV)
MyApp().run()
输出:

使用a作为根窗口小部件,以便将透明的BoxLayout放置在顶部。至于透明度,请使用按钮的

片段 例子 main.py 输出

使用a作为根窗口小部件,以便将透明的BoxLayout放置在顶部。至于透明度,请使用按钮的

片段 例子 main.py 输出

FloatLayout:
...
    # topBox
    BoxLayout:
        Button:
            text: 'Five (with transparent red background)'
            background_normal: ''
            background_color: 0.8, 0, 0, 0.5  # 5% red
            size_hint: (0.5, 0.1)
            pos_hint: {'top': 1}
from kivy.lang import Builder
from kivy.base import runTouchApp

runTouchApp(Builder.load_string('''
FloatLayout:
    size: (300, 300)

    # superBox
    BoxLayout:
        orientation: 'vertical'

        # horizontalBox
        BoxLayout:
            # orientation: 'horizontal' - default orientation is horizontal
            Button:
                text: 'One'
            Button:
                text: 'Two'

        # verticalBox
        BoxLayout:
            orientation: 'vertical'
            Button:
                text: 'Three'
            Button:
                text: 'Four'

    # topBox
    BoxLayout:
        Button:
            text: 'Five (with transparent red background)'
            background_normal: ''
            background_color: 0.8, 0, 0, 0.5  # 5% red
            size_hint: (0.5, 0.1)
            pos_hint: {'top': 1}

'''))