I
I
idwdino2022-04-20 19:18:13
PyQt
idwdino, 2022-04-20 19:18:13

How to stack radiobutton text values?

I have 70 ~ radio buttons, every 6 are inserted into groups of boxes, I need to multiply these radio button values, I just can’t find how626031fd69f7c177649261.jpeg

self.Button_result.setText(_translate("MainWindow", "PushButton"))
        self.radioButton_4.setText(_translate("MainWindow", "2"))
        self.radioButton_3.setText(_translate("MainWindow", "3"))
        self.radioButton_2.setText(_translate("MainWindow", "4"))
        self.radioButton_6.setText(_translate("MainWindow", "5"))
        self.radioButton_5.setText(_translate("MainWindow", "6"))
        self.radioButton.setText(_translate("MainWindow", "7"))
        self.radioButton_7.setText(_translate("MainWindow", "8"))
        self.radioButton_8.setText(_translate("MainWindow", "0"))
        self.radioButton_9.setText(_translate("MainWindow", "0"))
        self.radioButton_10.setText(_translate("MainWindow", "0"))
        self.radioButton_11.setText(_translate("MainWindow", "0"))
        self.radioButton_12.setText(_translate("MainWindow", "0"))
        self.radioButton_13.setText(_translate("MainWindow", "0"))
        self.radioButton_14.setText(_translate("MainWindow", "0"))
        self.radioButton_15.setText(_translate("MainWindow", "0"))
        self.radioButton_16.setText(_translate("MainWindow", "0"))
        self.radioButton_17.setText(_translate("MainWindow", "0"))
        self.radioButton_18.setText(_translate("MainWindow", "0"))
        self.radioButton_19.setText(_translate("MainWindow", "0"))
        self.radioButton_20.setText(_translate("MainWindow", "0"))
        self.radioButton_21.setText(_translate("MainWindow", "0"))
        self.radioButton_22.setText(_translate("MainWindow", "0"))
        self.radioButton_23.setText(_translate("MainWindow", "0"))
        self.radioButton_24.setText(_translate("MainWindow", "0"))
        self.radioButton_31.setText(_translate("MainWindow", "0"))
        self.radioButton_32.setText(_translate("MainWindow", "0"))
        self.radioButton_33.setText(_translate("MainWindow", "0"))
        self.radioButton_34.setText(_translate("MainWindow", "0"))
        self.radioButton_35.setText(_translate("MainWindow", "0"))
        self.radioButton_36.setText(_translate("MainWindow", "0"))
        self.radioButton_37.setText(_translate("MainWindow", "0"))
        self.radioButton_38.setText(_translate("MainWindow", "0"))
        self.radioButton_39.setText(_translate("MainWindow", "0"))
        self.radioButton_40.setText(_translate("MainWindow", "0"))
        self.radioButton_41.setText(_translate("MainWindow", "0"))
        self.radioButton_42.setText(_translate("MainWindow", "0"))
        self.radioButton_43.setText(_translate("MainWindow", "0"))
        self.radioButton_44.setText(_translate("MainWindow", "0"))
        self.radioButton_45.setText(_translate("MainWindow", "0"))
        self.radioButton_46.setText(_translate("MainWindow", "0"))
        self.radioButton_47.setText(_translate("MainWindow", "0"))
        self.radioButton_48.setText(_translate("MainWindow", "0"))
        self.radioButton_49.setText(_translate("MainWindow", "0"))
        self.radioButton_50.setText(_translate("MainWindow", "0"))
        self.radioButton_51.setText(_translate("MainWindow", "0"))
        self.radioButton_52.setText(_translate("MainWindow", "0"))
        self.radioButton_53.setText(_translate("MainWindow", "0"))
        self.radioButton_54.setText(_translate("MainWindow", "0"))
        self.radioButton_55.setText(_translate("MainWindow", "0"))
        self.radioButton_56.setText(_translate("MainWindow", "0"))
        self.radioButton_57.setText(_translate("MainWindow", "0"))
        self.radioButton_58.setText(_translate("MainWindow", "0"))
        self.radioButton_59.setText(_translate("MainWindow", "0"))
        self.radioButton_60.setText(_translate("MainWindow", "0"))
        self.radioButton_61.setText(_translate("MainWindow", "0"))
        self.radioButton_62.setText(_translate("MainWindow", "0"))
        self.radioButton_63.setText(_translate("MainWindow", "0"))
        self.radioButton_64.setText(_translate("MainWindow", "0"))
        self.radioButton_65.setText(_translate("MainWindow", "0"))
        self.radioButton_66.setText(_translate("MainWindow", "0"))
        self.radioButton_67.setText(_translate("MainWindow", "0"))
        self.radioButton_68.setText(_translate("MainWindow", "0"))
        self.radioButton_69.setText(_translate("MainWindow", "0"))
        self.radioButton_70.setText(_translate("MainWindow", "0"))
        self.radioButton_71.setText(_translate("MainWindow", "0"))
        self.radioButton_72.setText(_translate("MainWindow", "0"))
        self.radioButton_73.setText(_translate("MainWindow", "0"))
        self.radioButton_74.setText(_translate("MainWindow", "0"))
        self.radioButton_75.setText(_translate("MainWindow", "0"))
        self.radioButton_76.setText(_translate("MainWindow", "0"))
        self.radioButton_77.setText(_translate("MainWindow", "0"))
        self.radioButton_78.setText(_translate("MainWindow", "0"))
        self.radioButton_79.setText(_translate("MainWindow", "0"))
        self.radioButton_80.setText(_translate("MainWindow", "0"))
        self.radioButton_81.setText(_translate("MainWindow", "0"))
        self.radioButton_82.setText(_translate("MainWindow", "0"))
        self.radioButton_83.setText(_translate("MainWindow", "0"))
        self.radioButton_84.setText(_translate("MainWindow", "0"))
        self.radioButton_85.setText(_translate("MainWindow", "0"))
        self.radioButton_86.setText(_translate("MainWindow", "0"))
        self.radioButton_87.setText(_translate("MainWindow", "0"))
        self.radioButton_88.setText(_translate("MainWindow", "0"))
        self.radioButton_89.setText(_translate("MainWindow", "0"))
        self.radioButton_90.setText(_translate("MainWindow", "0"))
        self.radioButton_91.setText(_translate("MainWindow", "0"))
        self.radioButton_92.setText(_translate("MainWindow", "0"))
        self.radioButton_93.setText(_translate("MainWindow", "0"))
        self.radioButton_94.setText(_translate("MainWindow", "0"))
        self.radioButton_95.setText(_translate("MainWindow", "0"))
        self.radioButton_96.setText(_translate("MainWindow", "0"))
  
if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec())

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
seven5674, 2022-04-21
@idwdino

Here is an example for the sum
How to multiply I think you can guess

The code

from PyQt5.QtWidgets import *
import sys

class Window(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        layout = QVBoxLayout()
        self.setLayout(layout)
        self.label = QLabel("Сумма = 0")
        layout.addWidget(self.label)

        self.sum = 0
        self.gb_list = {}

        for i in range(1, 10):
            gb_layout = QHBoxLayout()
            gb_widget = QWidget()
            gb_widget.setLayout(gb_layout)
            gb = QButtonGroup(gb_widget)
            for j in range(1, 10):
                radiobutton = QRadioButton()
                radiobutton.setChecked(False)
                radiobutton.number = "{}".format(i)
                radiobutton.value = "{}".format(j)
                radiobutton.toggled.connect(self.onClicked)
                gb.addButton(radiobutton)
                gb_layout.addWidget(radiobutton)
            layout.addWidget(gb_widget)

    def onClicked(self):
        radioButton = self.sender()
        if radioButton.isChecked():
            self.gb_list[radioButton.number] = int(radioButton.value)
            self.label.setText("Сумма = {}".format(sum(self.gb_list.values())))

app = QApplication(sys.argv)
screen = Window()
screen.show()
sys.exit(app.exec_())


6260e8f1e1e71034253044.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question