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

        <bdo id='pzNgE'></bdo><ul id='pzNgE'></ul>
    2. <small id='pzNgE'></small><noframes id='pzNgE'>

    3. <legend id='pzNgE'><style id='pzNgE'><dir id='pzNgE'><q id='pzNgE'></q></dir></style></legend>

      在 PyQT4 中使用循环创建按钮网格

      Create a grid of buttons using a loop in PyQT4(在 PyQT4 中使用循环创建按钮网格)

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

                  <tbody id='3m8n2'></tbody>

                <small id='3m8n2'></small><noframes id='3m8n2'>

              • 本文介绍了在 PyQT4 中使用循环创建按钮网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                有没有办法在 PyQT4 中使用循环创建按钮网格?

                Is there a way to create a grid of buttons using a loop in PyQT4?

                例如,具有以下效果的东西:

                So for example, something that has the effect of:

                for j in range(0, 10):
                    for k in range(0, 10):
                        grid.addbutton(j, k)
                

                谢谢.

                推荐答案

                当然有.QGridLayout 可能有用在这种情况下.

                Sure there is. QGridLayout might be useful in this case.

                这是一个最小的例子:

                import sys
                from PyQt4 import QtGui
                
                app = QtGui.QApplication(sys.argv)
                widget = QtGui.QWidget()
                layout = QtGui.QGridLayout()
                
                buttons = {}
                
                for i in range(10):
                    for j in range(10):
                        # keep a reference to the buttons
                        buttons[(i, j)] = QtGui.QPushButton('row %d, col %d' % (i, j))
                        # add to the layout
                        layout.addWidget(buttons[(i, j)], i, j)
                
                widget.setLayout(layout)
                widget.show()
                sys.exit(app.exec_())
                

                结果:

                这篇关于在 PyQT4 中使用循环创建按钮网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                Pythonic and efficient way of finding adjacent cells in grid(在网格中查找相邻单元格的 Pythonic 和有效方法)
                map a hexagonal grid in matplotlib(在 matplotlib 中映射六边形网格)
                Execute arbitrary python code remotely - can it be done?(远程执行任意 python 代码 - 可以吗?)
                Python - Plotting colored grid based on values(Python - 根据值绘制彩色网格)
                Is there a GUI design app for the Tkinter / grid geometry?(是否有 Tkinter/网格几何图形的 GUI 设计应用程序?)
                tkinter Canvas Scrollbar with Grid?(带有网格的 tkinter 画布滚动条?)

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

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

                        <tbody id='KBtXS'></tbody>

                        • <bdo id='KBtXS'></bdo><ul id='KBtXS'></ul>

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

                          <tfoot id='KBtXS'></tfoot>