<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 中使用循环创建按钮网格

      时间:2023-07-23

          <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 中使用循环创建按钮网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:Python Tkinter 网格复选框 下一篇:使用 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>

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

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

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