pyqt signal送信パラメータのタイプ
'''
conclusion:
QtCore.pyqtSignal is able to send several types of variable
including int QString QStringList list dict
'''
from PyQt4 import QtGui, QtCore
import sys
class prowler(QtGui.QWidget):
switchSig = QtCore.pyqtSignal(dict)
def __init__(self, parent=None):
super(prowler, self).__init__(parent)
btnLayout = QtGui.QHBoxLayout()
mainLayout = QtGui.QVBoxLayout()
okBtn = QtGui.QPushButton("OK")
applyBtn = QtGui.QPushButton("b")
quitBtn = QtGui.QPushButton("c")
btnLayout.addStretch()
btnLayout.addWidget(okBtn)
btnLayout.addWidget(applyBtn)
btnLayout.addWidget(quitBtn)
mainLayout.addLayout(btnLayout)
self.setLayout(mainLayout)
okBtn.clicked.connect(self.callforhelp)
def callforhelp(self):
self.switchSig.emit({"mon":1, "tue":2, "wen":3})
class main(QtGui.QWidget):
def __init__(self, parent=None):
super(main, self).__init__(parent)
widget = prowler(self)
mainLayout = QtGui.QVBoxLayout()
mainLayout.addWidget(widget)
self.setLayout(mainLayout)
widget.switchSig.connect(self.reaction)
def reaction(self, string):
print string
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
Jenney = main()
Jenney.show()
sys.exit(app.exec_())
pyqtのsignalがemitできるパラメータタイプについてずっと迷っています.
今日やってみたら、タイプ的な制限はほとんどなく、使いやすいです