37,719
社区成员
发帖
与我相关
我的任务
分享
[code=python]
[/code]谢谢楼上,以下是我的全部代码
以下是我的代码,循环查询64个复选框是否被选中那段函数应该是有问题的,我不知道该怎么遍历,请指教,谢谢!
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'Dialog1.ui'
#
# Created by: PyQt4 UI code generator 4.11.4
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName(_fromUtf8("Dialog"))
Dialog.resize(975, 693)
self.layoutWidget = QtGui.QWidget(Dialog)
self.layoutWidget.setGeometry(QtCore.QRect(-10, 20, 2, 2))
self.layoutWidget.setObjectName(_fromUtf8("layoutWidget"))
self.horizontalLayout_4 = QtGui.QHBoxLayout(self.layoutWidget)
self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4"))
self.tabWidget = QtGui.QTabWidget(Dialog)
self.tabWidget.setGeometry(QtCore.QRect(20, 20, 881, 531))
self.tabWidget.setObjectName(_fromUtf8("tabWidget"))
self.tab = QtGui.QWidget()
self.tab.setObjectName(_fromUtf8("tab"))
self.layoutWidget_2 = QtGui.QWidget(self.tab)
self.layoutWidget_2.setGeometry(QtCore.QRect(10, 60, 731, 351))
self.layoutWidget_2.setObjectName(_fromUtf8("layoutWidget_2"))
self.horizontalLayout_3 = QtGui.QHBoxLayout(self.layoutWidget_2)
self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3"))
self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
self.verticalLayout = QtGui.QVBoxLayout()
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.checkBox_1 = QtGui.QCheckBox(self.layoutWidget_2)
self.checkBox_1.setObjectName(_fromUtf8("checkBox_1"))
self.verticalLayout.addWidget(self.checkBox_1)
self.checkBox_2 = QtGui.QCheckBox(self.layoutWidget_2)
self.checkBox_2.setObjectName(_fromUtf8("checkBox_2"))
self.verticalLayout.addWidget(self.checkBox_2)
self.checkBox_3 = QtGui.QCheckBox(self.layoutWidget_2)
self.checkBox_3.setObjectName(_fromUtf8("checkBox_3"))
self.verticalLayout.addWidget(self.checkBox_3)
//此处省略了checkBox_4到checkBox_60的部分
self.checkBox_61 = QtGui.QCheckBox(self.layoutWidget_8)
self.checkBox_61.setObjectName(_fromUtf8("checkBox_61"))
self.verticalLayout_32.addWidget(self.checkBox_61)
self.checkBox_62 = QtGui.QCheckBox(self.layoutWidget_8)
self.checkBox_62.setObjectName(_fromUtf8("checkBox_62"))
self.verticalLayout_32.addWidget(self.checkBox_62)
self.checkBox_63 = QtGui.QCheckBox(self.layoutWidget_8)
self.checkBox_63.setObjectName(_fromUtf8("checkBox_63"))
self.verticalLayout_32.addWidget(self.checkBox_63)
self.checkBox_64 = QtGui.QCheckBox(self.layoutWidget_8)
self.checkBox_64.setObjectName(_fromUtf8("checkBox_64"))
self.verticalLayout_32.addWidget(self.checkBox_64)
self.horizontalLayout_29.addLayout(self.verticalLayout_32)
self.horizontalLayout_27.addLayout(self.horizontalLayout_29)
self.groupBox_14 = QtGui.QGroupBox(self.tab_4)
self.groupBox_14.setGeometry(QtCore.QRect(30, 60, 381, 391))
self.groupBox_14.setObjectName(_fromUtf8("groupBox_14"))
self.groupBox_13.raise_()
self.groupBox_14.raise_()
self.layoutWidget_8.raise_()
self.tabWidget.addTab(self.tab_4, _fromUtf8(""))
self.pushButton = QtGui.QPushButton(Dialog)
self.pushButton.setGeometry(QtCore.QRect(300, 600, 151, 61))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.layoutWidget.raise_()
self.tabWidget.raise_()
self.pushButton.raise_()
self.pushButton.raise_()
self.retranslateUi(Dialog)
self.tabWidget.setCurrentIndex(0)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
Dialog.setWindowTitle(_translate("Dialog", "Dialog", None))
self.checkBox_1.setText(_translate("Dialog", "pipe1", None))
self.checkBox_2.setText(_translate("Dialog", "pipe2", None))
self.checkBox_3.setText(_translate("Dialog", "pipe3", None))
//此处省略了checkBox_4到checkBox_60的部分
self.checkBox_60.setText(_translate("Dialog", "pipe60", None))
self.checkBox_61.setText(_translate("Dialog", "pipe61", None))
self.checkBox_62.setText(_translate("Dialog", "pipe62", None))
self.checkBox_63.setText(_translate("Dialog", "pipe63", None))
self.checkBox_64.setText(_translate("Dialog", "pipe64", None))
self.groupBox_14.setTitle(_translate("Dialog", "pipe1-8", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_4), _translate("Dialog", "DFE3", None))
self.pushButton.setText(_translate("Dialog", "Start", None))
QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL(_fromUtf8("clicked()")),self.begin)
def begin(self):
for pipe in range(1,65):
m="checkBox_"+str(pipe)
if self.m.isChecked():
print("pipe"),
print(pipe),
print("is selected!!!")
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
#app.aboutToQuit.connect(app.deleteLater)
Dialog = QtGui.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())