【发布时间】:2017-01-18 09:17:00
【问题描述】:
先生们。
我有非常简单的 PyQT5 应用程序。 我已经动态创建了按钮并连接了一些功能。
class App(QWidget):
...
def createButtons(self):
...
for param in params:
print("placing button "+param)
button = QPushButton(param, checkable=True)
button.clicked.connect(lambda: self.commander())
我有指挥官方法:
def commander(self):
print(self.sender().text())
所以我可以访问单击的按钮。 但是,如果我想访问以前单击的按钮怎么办?还是主窗口中的另一个元素?怎么做?
我想要什么:
def commander(self):
print(self.sender().text())
pressedbutton = self.findButtonByText("testbutton")
pressedbutton.setChecked(False)
或者
pressedbutton = self.findButtonBySomeKindOfID(3)
pressedbutton.setChecked(False)
任何帮助将不胜感激!
【问题讨论】:
标签: python pyqt5 qpushbutton