1

私は15の防御を持っています。15 個のラジオボタン (p1、p2、p3.....p15) があります。QPush ボタンを 1 つ持っています。最初の定義を使用したい場合は、QPushButton の「p1」をクリックしてから、この定義を使用します。なぜ私はそれが必要なのですか?テキストを処理する必要があるため、テキストをテキスト編集で開き、処理する必要がありますが、ラジオボタンを使用して 1 つの定義のみを使用したいと考えています。どうすればできますか?

例えば:

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)       
4

1 に答える 1

1

最初に、チェックされたラジオ ボタンを見つける必要があります。次に、そのボタンに割り当てられた機能を次のように実行できます。

for radioButton in self.findChildren(QtGui.QRadioButton):
    if radioButton.isChecked():
        radioButtonText = radioButton.text()
        print "Radio Button Selected: ", radioButtonText
        if radioButtonText == "example":
            example(args) 
于 2013-02-21T06:54:09.947 に答える