Reputation: 339
I have 15 def's. I have 15 radiobuttons (p1,p2,p3.....p15). I have 1 QPush Button. When i want to use my first def, i select "p1" click on my QPushButton and then use this def. Why i need it? because i need process texts, i open a text into my textedit and i need process it, but i want to use only one def using radiobutton. How can i do it?
for example:
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))
and
def example(exampless):
example = []
for exx in exampless:
es = re.findall("\.{3}!", exx)
if es:
example = example + [exx]
#endif
#endfor
self.TextProcess.setPlainText(example)
Upvotes: 1
Views: 3416
Reputation:
First you'll need to find the checked radio button, then you can run the function assigned to that button, something like this:
for radioButton in self.findChildren(QtGui.QRadioButton):
if radioButton.isChecked():
radioButtonText = radioButton.text()
print "Radio Button Selected: ", radioButtonText
if radioButtonText == "example":
example(args)
Upvotes: 1