gpt4 book ai didi

python - pyqt4 + 单选按钮

转载 作者:太空宇宙 更新时间:2023-11-03 19:05:00 24 4
gpt4 key购买 nike

我有 15 个防御。我有 15 个单选按钮(p1、p2、p3.....p15)。我有 1 个 QPush 按钮。当我想使用我的第一个定义时,我选择“p1”,单击我的 QPushButton,然后使用这个定义。为什么我需要它?因为我需要处理文本,所以我在文本编辑中打开文本并且需要处理它,但我只想使用单选按钮使用一个定义。我该怎么做?

例如:

self.radioButton_1 = QRadioButton(self.Processing)
self.radioButton_1.setGeometry(QRect(520, 200, 50, 22))
self.radioButton_1.setObjectName(_fromUtf8("radioButton_1"))
self.radioButton_1.setText(QApplication.translate("Form", "P1", None, QApplication.UnicodeUTF8))
self.processLineButton = QPushButton(self.Processing)
self.processLineButton.setGeometry(QRect(800, 100, 100, 37))
self.processLineButton.setText(QApplication.translate("None","Process", None, QApplication.UnicodeUTF8))

   def example(exampless):     
example = []
for exx in exampless:
es = re.findall("\.{3}!", exx)
if es:
example = example + [exx]
#endif
#endfor

self.TextProcess.setPlainText(example)

最佳答案

首先,您需要找到选中的单选按钮,然后您可以运行分配给该按钮的功能,如下所示:

for radioButton in self.findChildren(QtGui.QRadioButton):
if radioButton.isChecked():
radioButtonText = radioButton.text()
print "Radio Button Selected: ", radioButtonText
if radioButtonText == "example":
example(args)

关于python - pyqt4 + 单选按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14987355/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com