<legend id='U3SJi'><style id='U3SJi'><dir id='U3SJi'><q id='U3SJi'></q></dir></style></legend>

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

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

      带有boxlayout的kivy滚动视图

      时间:2023-10-09

          • <bdo id='9UUPG'></bdo><ul id='9UUPG'></ul>
          • <small id='9UUPG'></small><noframes id='9UUPG'>

              <tfoot id='9UUPG'></tfoot>
              • <i id='9UUPG'><tr id='9UUPG'><dt id='9UUPG'><q id='9UUPG'><span id='9UUPG'><b id='9UUPG'><form id='9UUPG'><ins id='9UUPG'></ins><ul id='9UUPG'></ul><sub id='9UUPG'></sub></form><legend id='9UUPG'></legend><bdo id='9UUPG'><pre id='9UUPG'><center id='9UUPG'></center></pre></bdo></b><th id='9UUPG'></th></span></q></dt></tr></i><div id='9UUPG'><tfoot id='9UUPG'></tfoot><dl id='9UUPG'><fieldset id='9UUPG'></fieldset></dl></div>
                <legend id='9UUPG'><style id='9UUPG'><dir id='9UUPG'><q id='9UUPG'></q></dir></style></legend>
                  <tbody id='9UUPG'></tbody>
              • 本文介绍了带有boxlayout的kivy滚动视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我目前正在熟悉 kivy.我认为它有很大的潜力,但我确实发现普通 python"和 kv 语言之间的关系有点令人困惑,这使得很难理解在哪里做项目.目前在我看来,使用 python 与 kv-l 时的行为(幕后发生的事情)并不是一对一的,总的来说,我认为这使得可用性/生产力的标准相当高.

                I'm at the moment getting familiar with kivy. I think it has great potential, but I do find the relationship between "normal python" and the kv-language a bit confusing which makes it hard to understand where to do items. At the moment it appears to me that the behaviour (the things that happens behind the scenes) is not one to one when using python vs kv-l, in general I think that makes the bar quite high for usability/productivity.

                我和其他人一起使用了速成课程",这是获得对 kivy 第一印象的良好开端.无论如何,在学习的过程中,我只是想看看我是否可以制作一个可滚动的 box-view - 结果我做不到.

                I've amongst others used the "crash course" by inclement which is a great start to get a first impression of kivy. Anyway, in the process of learning I just wanted to see if I could make a box-view scrollable - it turned out that I could not.

                需要什么才能使这段代码正常工作,即将标签扩展到它们的纹理大小",同时拥有一个可以调整的 ScrollView?

                What's needed to make this code work, i.e. expand the labels to their "texture-size", and at the same time having a ScrollView that adjusts to that?

                如果 BoxLayout 有 size_hint_y: None,则标签不会扩展到文本,但是当窗口非常小时,可以看到滚动视图.

                If the BoxLayout has a size_hint_y: None, the labels are not expanded to the text, but the scrollview can be seen in action when making the window really small.

                如果 BoxLayout 有 size_hint_y: 1,则标签会展开,但显然 boxlayout 的高度根本没有改变,即滚动视图窗口似乎与 size_hint_y: None 相同

                If the BoxLayout has a size_hint_y: 1, the labels are expanded, but apparantly the height of the boxlayout does not change at all, i.e. the scrollview window seems to be the same as with size_hint_y: None

                如果我只是输入一个很大的高度,滚动视图会覆盖它,但我希望可以获得与其内容耦合的 boxlayout 的动态高度.

                If I just put in a height which is large, the scrollview covers this, but I would expect that it's possible to get a dynamic height of the boxlayout coupled to it's content.

                我玩过高度、size_hints 等,但我没有找到有效的组合,有时会收到警告说由于内部重绘循环需​​要重新编写代码?

                I've played around with heights, size_hints, etc. and I have not found a combination that works and sometimes get warnings that the code needs to be remade due to internal redrawing loops?

                我错过/不理解什么?

                代码如下.

                from kivy.base import runTouchApp
                from kivy.lang import Builder
                from kivy.uix.scrollview import ScrollView
                
                Builder.load_string("""
                
                <ScrollableLabel>:
                    BoxLayout:
                        orientation: 'vertical'
                        # size_hint_y: 1
                        size_hint_y: None
                        height: 400 #self.size[1]
                        canvas:
                            Color:
                                rgba: (1, 0, 0, .5) # DarkOliveGreen
                            Rectangle:
                                size: self.size
                                pos: self.pos
                        Label:
                            id: bust
                            text: 'a string that is long ' * 10
                            font_size: 50
                            text_size: self.width, None
                            size_hint_y: None
                            height: self.texture_size[1]
                            canvas:
                                Color:
                                    rgba: (0, 1, 0, .5) # DarkOliveGreen
                                Rectangle:
                                    size: self.size
                                    pos: self.pos
                        Label:
                            text: '2 strings that are long ' * 10
                            text_size: self.width, None
                            size_hint_y: None
                            height: self.texture_size[1]
                        Button:
                            text: 'just testing'
                
                
                
                """)
                
                class ScrollableLabel(ScrollView):
                    pass
                
                runTouchApp(ScrollableLabel())
                

                推荐答案

                BoxLayout 的设计目的是让它的子元素填充自己.您想要的动态调整大小的更好布局是 GridLayout,它有一个可以绑定到自动调整大小的 minimum_height.

                The BoxLayout is designed to make its children fill itself. A better layout for the dynamic resizing you want is the GridLayout, which has a minimum_height you can bind to for automatic resizing.

                <ScrollableLabel>:
                    GridLayout:
                        cols: 1
                        size_hint_y: None
                        height: self.minimum_height
                        canvas:
                            Color:
                                rgba: (1, 0, 0, .5) # DarkOliveGreen
                            Rectangle:
                                size: self.size
                                pos: self.pos
                        Label:
                            id: bust
                            text: 'a string that is long ' * 10
                            font_size: 50
                            text_size: self.width, None
                            size_hint_y: None
                            height: self.texture_size[1]
                            canvas:
                                Color:
                                    rgba: (0, 1, 0, .5) # DarkOliveGreen
                                Rectangle:
                                    size: self.size
                                    pos: self.pos
                        Label:
                            text: '2 strings that are long ' * 10
                            text_size: self.width, None
                            size_hint_y: None
                            height: self.texture_size[1]
                        Button:
                            text: 'just testing'
                """)
                

                这篇关于带有boxlayout的kivy滚动视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何分析 Kivy 应用程序? 下一篇:为什么不能从 Kivy 终止这个 Python 多处理进程?

                相关文章

                最新文章

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

                  1. <small id='4waLk'></small><noframes id='4waLk'>