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

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

          <bdo id='YFKTP'></bdo><ul id='YFKTP'></ul>

        是否可以在 kivy GridLayout 中为特定小部件指定特定网格

        Is it possible in kivy GridLayout to specify a particular grid for a particular widget(是否可以在 kivy GridLayout 中为特定小部件指定特定网格)
          <tbody id='48dPt'></tbody>

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

              <small id='48dPt'></small><noframes id='48dPt'>

                  本文介绍了是否可以在 kivy GridLayout 中为特定小部件指定特定网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我一直在使用 PyQt,我知道如果我们使用QGridLayout 在 PyQt 中,我们可以在特定的网格中指定特定的小部件.

                  I have been using PyQt since a long time and i know that if we use QGridLayout in PyQt we can specify a particular widget at a particular grid.

                  例如

                  grid = QtGui.QGridLayout()
                  grid.setSpacing(10)
                  grid.addWidget(self.Banner,0,0,1,4,QtCore.Qt.AlignTop | QtCore.Qt.AlignCenter)
                  grid.addWidget(self.RefNo,1,0,1,2)
                  grid.addWidget(self.RefNoText,1,2,1,2)
                  

                  其中 self.bannerself.Refnoself.RefNoText 是一些小部件.在这种情况下,我们可以指定小部件,然后指定行号.对于它和列号.为了它.Kivy 有可能做到这一点吗?

                  where self.banner, self.Refno and self.RefNoText are some widgets. As in this case we can specify widget, then row no. For it and column no. For it. Is it possible in Kivy to do that?

                  我在 Kivy 中尝试过,但似乎在 Kivy 中我们必须在开始时指定行和列,然后在添加它们自己排列的小部件时?

                  I tried in Kivy but it seems that in Kivy we have to specify rows and columns in starting and then on adding widgets they are arranged by themselves?

                  有什么想法吗?

                  推荐答案

                  在 Kivy 中,当我们将小部件添加到 GridLayout 时,我们只需指定行、列或两者.

                  In Kivy, when we add widgets to a GridLayout, we just specify either the rows, columns or both.

                  然后我们将定位留给 Kivy,它会根据我们的规范自动填充它.

                  We then leave the positioning to Kivy which automatically fills it as per our specifications.

                  查看 GridLayout 的官方文档

                  有一个非常好的 .gif 文件,它解释了小部件在 GridLayout 中的排列方式.

                  There is a really nice .gif which explains how widgets are arranged in a GridLayout.

                  所以,您的问题的答案是否定的.我们无法指定要放置小部件的位置,但是,我们所能做的就是以正确定位的方式将小部件添加到 GridLayout.

                  So, the answer to your question is NO. We cannot specify where we want to place a widget, however, all that we can do is add widgets to the GridLayout in such a manner that it positions it correctly.

                  最初,我发现很难让小部件占用比一个单元格更多的空间,如下所示:

                  Initially, I found difficulties in making a widget occupy more space than once cell, like this:

                  <2 cells><1cell>
                  +--------+-----+
                  |Big     |     |
                  |Widget  |     |
                  +--------+-----+
                  |   |    |     |
                  |   |    |     |
                  +---+----+-----+
                  

                  但是,这可以通过将整行设为 BoxLayout 来解决.像这样:

                  However, this can be solved making the entire row a BoxLayout. Like so:

                  <1 big BoxLayout>
                  +--------+-----+
                  |Big     |     |
                  |Widget  |     |
                  +--------+-----+
                  |   |    |     |
                  |   |    |     |
                  +---+----+-----+
                  <1 more BoxLayout>
                  

                  这样,每个 BoxLayout 只占用一个单元格.可以通过 BoxLayout 自定义小部件的间距,然后放置在 Grid 中.

                  This way, each BoxLayout occupies only one cell. The spacing of the widgets can be customized with the BoxLayout and then be placed in the Grid.

                  下面是如何在 Kv 中做到这一点:

                  Here's how to do that in Kv:

                  <MyGrid>
                      cols=1 # Actually, you can just use a vertical box
                  
                      BoxLayout:
                  
                          BigWidget:
                              # Properties
                          SmallWidget:
                              # Properties
                  
                      BoxLayout:
                  
                          SmallWidget:
                              # Properties
                          SmallWidget:
                              # Properties
                          SmallWidget:
                              # Properties
                  

                  Kivy 会自动用 1 列填充 Grid

                  Kivy will automatically fill the Grid with 1 column

                  因此,通过嵌套布局,您可以获得所需的输出.

                  So, by nesting layouts you can get the desired output.

                  这篇关于是否可以在 kivy GridLayout 中为特定小部件指定特定网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Kivy 1.9.0 Windows package KeyError: #39;rthooks#39;(Kivy 1.9.0 Windows 包 KeyError: rthooks)
                  Python Kivy: how to call a function on button click?(Python Kivy:如何在按钮单击时调用函数?)
                  How to disable a widget in Kivy?(如何禁用 Kivy 中的小部件?)
                  Centering an object in Kivy(在 Kivy 中将对象居中)
                  How to downgrade to Python 3.4 from 3.5(如何从 Python 3.5 降级到 Python 3.4)
                  Change button or label text color in kivy(在kivy中更改按钮或标签文本颜色)
                    • <small id='TmYDg'></small><noframes id='TmYDg'>

                      <tfoot id='TmYDg'></tfoot>
                        <tbody id='TmYDg'></tbody>
                        <bdo id='TmYDg'></bdo><ul id='TmYDg'></ul>

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

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