A
A
AirronBark2022-01-30 18:23:06
PyQt
AirronBark, 2022-01-30 18:23:06

How to take value from generated QSpinBox?

I set the number of spinBoxes in the previous window and then, according to the code below, they are located in the next window, but when the button is pressed, I need to take the value from each generated spinbox, but at the moment only the value from the last one is transmitted.
How can I access each spinbox? And I would like to hear how the name of the self.quantity_pp variable is formed (it cannot be repeated?).

class CreateSpuWindow(QMainWindow):
    def __init__(self, value):
        super().__init__()
        uic.loadUi('ui/statement_spu_1.ui', self)
        self.value = value  # Количество spinBox 
        for i in range(value):
            self.spu_label = QLabel(self)
            self.spu_label.setText(f"СПУ №{i+1}. Количество ПП:")
            self.quantity_pp = QSpinBox(self)
            self.quantity_pp.setValue(1)
            self.quantity_pp.setMinimum(1)
            self.gridLayout_2.addWidget(self.spu_label, 2 * i, 0)
            self.gridLayout_2.addWidget(self.quantity_pp, 2 * i, 1)
        self.next_tu_spu_2Button.clicked.connect(self.next_wind_spu_btn)
        self.back_btn.clicked.connect(self.back_btn_cl)

    def next_wind_spu_btn(self):
        data = []
        # Забор значений из spinBox
        for i in str(self.quantity_pp.value()):
            data.append(i)
        print(data)
        quantity_spu = self.value
        self.ReadyTableSpuWindow = ReadyTableSpuWindow(quantity_spu)
        self.ReadyTableSpuWindow.show()
        self.close()

    def back_btn_cl(self):
        self.close()
        self.QuantitySpuWindow = QuantitySpuWindow()
        self.QuantitySpuWindow.show()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2022-01-30
@Vindicar

Open the lists for yourself .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question