jeudi 5 août 2021

How can i append True checkboxes to a list using PyQt5?

Code:

class Window2(QWidget):
def __init__(self,fname):
    self.adat = datas.Data(fname)
    self.tmp_lst = []
    super().__init__()
    self.setWindowTitle('Excel sheet')
    self.adat.x_y()

    self.setGeometry(self.adat.x_y()[0],self.adat.x_y()[1],self.adat.x_y()[2],self.adat.x_y()[3])

    layout = QGridLayout()
    self.setLayout(layout)

    self.rownum = 5
    self.colnum = 0


    self.button_1 = QPushButton('Ok',self)
    self.button_1.resize(50,30)
    self.button_1.setGeometry(10,0,70,35)

    wb = load_workbook(filename = fname)

    for sheet in wb.sheetnames:
        self.cb = QCheckBox(sheet)
        self.cb.setChecked(False)
        if sheet == 'Főösszesítő' or ('Össz' or 'össz') in sheet:
            self.cb.setChecked(True)


        layout.addWidget(self.cb,self.rownum,self.colnum,15,10)
        self.rownum+=5

        if self.rownum > 70:
            self.colnum+=20
            self.rownum = 5

I would like to append the True elements to a list but i really don't know how can i do it. In my code i browse for a file and then a new window appears where i put the excel sheets' name to checkboxes and if the statement is True i want to add to a list, I tried so many ways but they were unsuccessful.




Aucun commentaire:

Enregistrer un commentaire