python - 当我点击 QPushButton 时,如何根据 QRadioButton 修改被调用的函数?
问题描述
我有三个 QRadioButtons。一次只能选择一个。我有一个 QPushButton,它必须根据所选的 QRadioButton 调用不同的函数。
示例:如果选择 QRadioButton #1,则该按钮在单击时执行功能 #1。如果选择 QRadioButton #2,则相同的按钮执行功能 #2,依此类推。
解决方案
我不得不为我的代码稍微改变一下,它确实有效。谢谢!
...
class Window(QWidget):
def __init__(self):
...
def init_ui(self):
...
self.bnt.clicked.connect(lambda: self.decision_maker())
...
def decision_maker(self):
if self.radiobutton1.isChecked():
do_something_1()
elif self.radiobutton2.isChecked():
do_something_2()
...
推荐阅读
- html - HTML 文件中的 Vaadin Maven 构建属性
- php - 如何在 php 中记住 GET 和 POST 值?
- postgresql - 根据多个参数搜索 postgres 表,但不需要全部
- bytecode - 重新定义 JDK Bootstrap 类
- ios - 如何在 scrollViewDidScroll 回调中使用滚动到单元格?
- python - 使用 flash() 时 Flask 出错:TypeError
- configuration - 更改 Umbraco 中包裹的默认位置
- javascript - JSON to HTML - 我被官方难住了
- octave - Lightspeed 中断 Octave Forge 软件包安装 - 未实现二进制运算符“==”
- javascript - 离子框架中的“=>”符号是什么意思?