1. <tfoot id='F5VYs'></tfoot>
      <legend id='F5VYs'><style id='F5VYs'><dir id='F5VYs'><q id='F5VYs'></q></dir></style></legend>
        <bdo id='F5VYs'></bdo><ul id='F5VYs'></ul>
      <i id='F5VYs'><tr id='F5VYs'><dt id='F5VYs'><q id='F5VYs'><span id='F5VYs'><b id='F5VYs'><form id='F5VYs'><ins id='F5VYs'></ins><ul id='F5VYs'></ul><sub id='F5VYs'></sub></form><legend id='F5VYs'></legend><bdo id='F5VYs'><pre id='F5VYs'><center id='F5VYs'></center></pre></bdo></b><th id='F5VYs'></th></span></q></dt></tr></i><div id='F5VYs'><tfoot id='F5VYs'></tfoot><dl id='F5VYs'><fieldset id='F5VYs'></fieldset></dl></div>

      <small id='F5VYs'></small><noframes id='F5VYs'>

      如何在 Kivy (Python) 中覆盖 2 个布局?

      时间:2023-10-09
    2. <i id='M5LNK'><tr id='M5LNK'><dt id='M5LNK'><q id='M5LNK'><span id='M5LNK'><b id='M5LNK'><form id='M5LNK'><ins id='M5LNK'></ins><ul id='M5LNK'></ul><sub id='M5LNK'></sub></form><legend id='M5LNK'></legend><bdo id='M5LNK'><pre id='M5LNK'><center id='M5LNK'></center></pre></bdo></b><th id='M5LNK'></th></span></q></dt></tr></i><div id='M5LNK'><tfoot id='M5LNK'></tfoot><dl id='M5LNK'><fieldset id='M5LNK'></fieldset></dl></div>
          <bdo id='M5LNK'></bdo><ul id='M5LNK'></ul>

              <legend id='M5LNK'><style id='M5LNK'><dir id='M5LNK'><q id='M5LNK'></q></dir></style></legend>
            • <small id='M5LNK'></small><noframes id='M5LNK'>

                <tbody id='M5LNK'></tbody>
                <tfoot id='M5LNK'></tfoot>

                本文介绍了如何在 Kivy (Python) 中覆盖 2 个布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在尝试制作一个具有背景网格和顶层交互元素的应用程序,我无法通过 python 覆盖第二层,所以就像标题所说的那样,有没有办法在 Kivy 中覆盖 2 个或多个布局在?

                这就是我要找的东西

                解决方案

                解决方案

                设置第一层/布局的opacity为0.5

                I am trying to make an app with a background grid and a top layer of interactive elements, I am having trouble overlaying the second layer via python, so like the title says is there a way to overlay 2 or more layouts in Kivy in ?

                Here's what I am looking for

                解决方案

                Solution

                Set the opacity of the first layer / layout to 0.5

                Widget class » opacity

                opacity

                Opacity of the widget and all its children.

                The opacity attribute controls the opacity of the widget and its children. Be careful, it’s a cumulative attribute: the value is multiplied by the current global opacity and the result is applied to the current context color.

                ...

                opacity is a NumericProperty and defaults to 1.0.

                Kivy Graphics Line » points

                points: list

                List of points in the format (x1, y1, x2, y2…)

                Property for getting/settings points of the line

                Warning

                This will always reconstruct the whole graphics from the new points list. It can be very CPU expensive.

                Kivy Graphics Line » circle

                circle

                Use this property to build a circle, without calculating the points. You can only set this property, not get it.

                The argument must be a tuple of (center_x, center_y, radius, angle_start, angle_end, segments):

                • center_x and center_y represent the center of the circle
                • radius represent the radius of the circle
                • (optional) angle_start and angle_end are in degree. The default value is 0 and 360.
                • (optional) segments is the precision of the ellipse. The default value is calculated from the range between angle.

                Note that it’s up to you to close the circle or not.

                Example

                main.py - without kv

                from kivy.base import runTouchApp
                from kivy.core.window import Window
                from kivy.uix.screenmanager import Screen
                from kivy.uix.boxlayout import BoxLayout
                from kivy.graphics import Color, Line
                from kivy.metrics import dp
                
                Window.clearcolor = (1, 1, 1, 1)
                
                
                class Overlay2Layouts(Screen):
                
                    def __init__(self, **kwargs):
                        super(Overlay2Layouts, self).__init__(**kwargs)
                        self.size = Window.size
                
                        layout1 = BoxLayout(opacity=0.5)
                        with layout1.canvas:
                            Color(1, 0, 0, 1)   # red colour
                            Line(points=[self.center_x, self.height / 4, self.center_x, self.height * 3/4], width=dp(2))
                            Line(points=[self.width * 3/ 4, self.center_y, self.width /4, self.center_y], width=dp(2))
                
                        layout2 = BoxLayout()
                        with layout2.canvas:
                            Color(0, 0, 0, 1)   # black colour
                            Line(circle=[self.center_x, self.center_y, 190], width=dp(2))
                
                        self.add_widget(layout1)
                        self.add_widget(layout2)
                
                
                if __name__ == "__main__":
                    runTouchApp(Overlay2Layouts())
                

                main.py - using kv and Python

                from kivy.lang import Builder
                from kivy.base import runTouchApp
                from kivy.core.window import Window
                
                Window.clearcolor = (1, 1, 1, 1)
                
                runTouchApp(Builder.load_string('''
                #:kivy 1.11.0
                
                Screen:
                    BoxLayout:
                        opacity: 0.5
                        canvas.before:
                            Color:
                                rgba: 1, 0, 0, 1
                            Line:
                                width: dp(2.)
                                points: [self.center_x, self.height / 4, self.center_x, self.height * 3/4]
                            Line:
                                width: dp(2.)
                                points: [root.width * 3/ 4, self.center_y, root.width /4, self.center_y]
                    BoxLayout:
                        canvas.before:
                            Color:
                                rgba: 1, 0, 0, 1
                            Line:
                                width: dp(2.)
                                circle: (root.center_x, root.center_y, 190)
                
                '''))
                

                Output

                这篇关于如何在 Kivy (Python) 中覆盖 2 个布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:为什么根小部件的窗口大小不同? 下一篇:Kivy VideoPlayer 全屏、循环和隐藏控件

                相关文章

                最新文章

                • <bdo id='55Jis'></bdo><ul id='55Jis'></ul>

              1. <legend id='55Jis'><style id='55Jis'><dir id='55Jis'><q id='55Jis'></q></dir></style></legend>

                1. <tfoot id='55Jis'></tfoot>

                    <small id='55Jis'></small><noframes id='55Jis'>

                    <i id='55Jis'><tr id='55Jis'><dt id='55Jis'><q id='55Jis'><span id='55Jis'><b id='55Jis'><form id='55Jis'><ins id='55Jis'></ins><ul id='55Jis'></ul><sub id='55Jis'></sub></form><legend id='55Jis'></legend><bdo id='55Jis'><pre id='55Jis'><center id='55Jis'></center></pre></bdo></b><th id='55Jis'></th></span></q></dt></tr></i><div id='55Jis'><tfoot id='55Jis'></tfoot><dl id='55Jis'><fieldset id='55Jis'></fieldset></dl></div>