我正在创建一个按钮字典:
self.edit = QtGui.QLabel('')
self.calcstring = ''
self.button = {}
for i in self.btn:
self.button[i] = QtGui.QPushButton(i)
if j == 2:
self.grid.addWidget(self.edit, 0, 2)
else:
self.grid.addWidget(self.button[i], pos[j][0], pos[j][1])
j += 1
现在所有人都应该得到点击函数:
^{pr2}$在这个函数中,按下的状态应该被读取,我这样做了:
def _action(self):
if self.button['1'].clicked():
sys.exit()
else:
self.update(self.calcstring)
但是按下按钮时的错误:
if self.button['1'].clicked():
TypeError: native Qt signal is not callable
怎么了?在
使用
self.sender()
获取触发事件的小部件,下面是一个示例:在您的情况下:
^{pr2}$相关问题 更多 >
编程相关推荐