PyQt4--QPushButton阵列
# -*- coding: utf-8 -*-
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
import functools
class Dialog(QDialog):
def __init__(self,parent=None):
super(Dialog,self).__init__(parent)
self.setButtons(row=5,column=5)
for row_index in range(len(self.btns)):
for column_index in range(len(self.btns[row_index])):
self.connect(self.btns[row_index][column_index],
SIGNAL('clicked()'),
functools.partial(self.btnClicked,row_index,column_index))
def setButtons(self,row=2,column=2):
self.btns=list()
for row_index in range(row):
row_btn=list()
for column_index in range(column):
btn=QPushButton('Row %d Column %d'%(row_index,column_index))
row_btn.append(btn)
self.btns.append(row_btn)
gridLayout=QGridLayout(self)
for row_index in range(row):
for column_index in range(column):
gridLayout.addWidget(self.btns[row_index][column_index],row_index,column_index)
def btnClicked(self,row_index,column_index):
QMessageBox.information(self,'Msg','Row %d, Column %d Button Clicked'%(row_index,column_index))
app=QApplication(sys.argv)
dlg=Dialog()
dlg.show()
sys.exit(app.exec_())

PyQt4--QPushButton阵列的更多相关文章
- PyQt4 QListWidget 使用教程
转自:http://blog.csdn.net/seeground/article/details/49177387?locationNum=3&fps=1 listWidget = QLis ...
- PyQt4入门学习笔记(五)
PyQt4里的对话框 对话框是大多数GUI应用中不可分割的一部分.一个对话框是两者或多者的会话.在GUI内,对话框是应用向人说话的方式.一个对话框可以用来输入数据,修改数据,改变应用设置等等. QtG ...
- PyQt4入门学习笔记(四)
在PyQt4中的事件和信号 事件 所有的GUI应用都是事件驱动的.事件主要是来自于应用的使用者,但是像互联网连接,窗口管理器或者计时器也可以产生事件.当我们调用应用的exec_()方法时,应用就进入了 ...
- PyQt4入门学习笔记(三)
# PyQt4入门学习笔记(三) PyQt4内的布局 布局方式是我们控制我们的GUI页面内各个控件的排放位置的.我们可以通过两种基本方式来控制: 1.绝对位置 2.layout类 绝对位置 这种方式要 ...
- 基于傅里叶变换和PyQt4开发一个简单的频率计数器
小学期的<信号与系统>课,要求写一个频率计数器,下面是我个人理解的频率计数 傅里叶变换的代码: # coding=utf-8 import numpy as np from scipy.i ...
- PyQt4入门学习笔记(一)
PyQt4入门学习笔记(一) 一直没有找到什么好的pyqt4的教程,偶然在google上搜到一篇不错的入门文档,翻译过来,留以后再复习. 原始链接如下: http://zetcode.com/gui/ ...
- [Repost]Events and Signals in PyQt4
Reference:http://zetcode.com/gui/pyqt4/eventsandsignals/ Events and Signals in PyQt4 In this part of ...
- python3.2 + PyQt4界面开发hello world
需要先安装python3.2 然后安装python3.2对应的PyQt4界面库版本 import sys from PyQt4 import QtGui , QtCore app = QtGui.QA ...
- py2.7+pyqt4开发端口检测工具
使用工具:python2.7,pyqt4,pyinstaller,pywin32 先贴代码 import sys from PyQt4 import QtGui,QtCore import threa ...
- PyQt4学习记录之事件和信号
事件是任何 GUI程序中很重要的部分.所有 Python GUI 应用都是事件驱动的.一个应用对其生命期产生的不同的事件类型做出反应.事件是主要由应用的用户产生.但是,也可以通过其他方法产生,比如,网 ...
随机推荐
- Apache https 配置指南
Windows Apache HTTPS配置创建下面3个目录: C:\Program Files\Apache Group\Apache2\conf\sslC:\Program Files\Apach ...
- [ES6] for..in && for..of
var ary = [ { id: 1, name: "Zhentian" }, { id: 2, name: "Alice" } ]; for..in Pri ...
- autochannel 指定栏目
(> DedeCMS 4,DedeCMS5) 名称:autochannel 功能:指定排序位置的单个栏目的链接 语法: {dede:autochannel partsort='2' typeid ...
- Android 自定义控件玩转字体变色 打造炫酷ViewPager指示器
1.概述 本篇博客的产生呢,是因为,群里的哥们暖暖给我发了个效果图,然后问我该如何实现顶部ViewPager指示器的字体变色,该效果图是这样的: 大概是今天头条的app,神奇的地方就在于,切换View ...
- javascript封装id|class|元素选择器
由于各个浏览器都支持的选择方法只有如下三种: 1 document.getElementById() 2 document.getElementsByName() 3 document.getElem ...
- 【转】 LINQ To SQL 语法及实例大全
LINQ to SQL语句(1)之Where Where操作 适用场景:实现过滤,查询等功能. 说明:与SQL命令中的Where作用相似,都是起到范围限定也就是过滤作用的,而判断条件就是它后面所接的子 ...
- html hack 列表
<!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]--> <!--[if IE]> 所有的IE可识别 <![ ...
- IDEA - Project files cannot be watched (are they under network mount?)
在64位Linux系统上使用IDEA时遇到如下问题,启动时警告信息External file changes sync may be slow Project files cannot be watc ...
- linux添加JAVA环境变量
root用户: 1.修改文件vim /etc/profile 添加以下信息: export JAVA_HOME=/home/jdk1..0_79 (这里需要添加自己的JDK安装目录) export C ...
- java线层的启动与停止
class Do8 { public static void main(String[] args) { Resource r =new Resource(); Input in =new Input ...