Python 基维:我想把窗口大小的按钮叠放在屏幕的顶部

Python 基维:我想把窗口大小的按钮叠放在屏幕的顶部,python,button,layout,kivy,transparent,Python,Button,Layout,Kivy,Transparent,我希望窗口大小的不透明黑色按钮堆叠在屏幕顶部 当我按下不透明的黑色按钮时,按钮将消失,下面的屏幕将可见。 我试过了,但总是失败 下面是我的代码(.py) 这是我的.kv文件: ScreenManagement: transition: First_Screen: <First_Screen>: #<-i want fullscreen-sized opaque black button covers #up this scree

我希望窗口大小的不透明黑色按钮堆叠在屏幕顶部 当我按下不透明的黑色按钮时,按钮将消失,下面的屏幕将可见。 我试过了,但总是失败

下面是我的代码(
.py

这是我的
.kv
文件:

ScreenManagement:
    transition:
    First_Screen:

<First_Screen>: #<-i want fullscreen-sized opaque black button covers
                #up this screen and will be disappear when i press the button
    name: 'First_Screen'
    BoxLayout:
        orientation: 'horizontal'
        spacing: 50 
        padding: [50, 50, 50, 50]
        canvas:
            Rectangle:
                pos: self.pos
                size: self.size 
                source: 'image/background.jpg'
        Button:
            id: campustown
            width: 40
            pos_hint: {'x' : 0, 'y':.45}
            size_hint: [.6,.1]
            background_normal:'image/test.png'
            background_down:'image/test2.png'
            border: (0,0,0,0)
            font_size: 15
            text: 'campus-town'
屏幕管理:
过渡:
第一个屏幕:
:#Python代码
  • class First\u Screen()中删除
    BoxLayout
  • 片段-Py kv文件
  • 为按钮添加一个释放事件
  • background\u normal
    设置为
    background\u down
  • 片段-kv
    :
    名称:“第一屏”
    按钮:
    id:坎普斯敦
    背景_正常:“image/test.png”
    背景:“image/test2.png”
    边界:(0,0,0,0)
    字体大小:15
    文字:“校园城”
    发布时:
    self.background\u normal=self.background\u down
    
    输出

    ScreenManagement:
        transition:
        First_Screen:
    
    <First_Screen>: #<-i want fullscreen-sized opaque black button covers
                    #up this screen and will be disappear when i press the button
        name: 'First_Screen'
        BoxLayout:
            orientation: 'horizontal'
            spacing: 50 
            padding: [50, 50, 50, 50]
            canvas:
                Rectangle:
                    pos: self.pos
                    size: self.size 
                    source: 'image/background.jpg'
            Button:
                id: campustown
                width: 40
                pos_hint: {'x' : 0, 'y':.45}
                size_hint: [.6,.1]
                background_normal:'image/test.png'
                background_down:'image/test2.png'
                border: (0,0,0,0)
                font_size: 15
                text: 'campus-town'
    
    class First_Screen(Screen):
        pass
    
    <First_Screen>:
        name: 'First_Screen'
    
        Button:
            id: campustown
            background_normal: 'image/test.png'
            background_down: 'image/test2.png'
            border: (0,0,0,0)
            font_size: 15
            text: 'campus-town'
            on_release:
                self.background_normal = self.background_down