jeudi 20 février 2020

In PyQt5 how to clear previous output of combo box

On-click of Combo box i am generating the check-boxes. i have to clear the previous output of combo-box problem is that i am generating check-boxes using list so that i cant use method Checkbox.clear().any one can suggest me how i can implement this.

def temp_var(self,text):

    cur_txt = text

    if cur_txt == 'Lab 1':

        file1=open("lab1","rt")
        self.checkboxlist = []
        for i in range(self.num_lines):
            r = file1.readline()
            self.checkboxlist.append(QtWidgets.QCheckBox(r, self.verticalLayoutWidget))
            self.verticalLayout.addWidget(self.checkboxlist[-1])
    elif(cur_txt == 'Lab 2'):
        file1 = open("lab2", "rt")
        self.checkboxlist = []
        for i in range(self.num_lines):
            r = file1.readline()

            self.checkboxlist.append(QtWidgets.QCheckBox(r, self.verticalLayoutWidget))
            # self.checkBox.setObjectName(str(count))
            # count+=1
            self.verticalLayout.addWidget(self.checkboxlist[-1])
    else:

        file1 = open("lab3", "rt")
        self.checkboxlist = []
        for i in range(self.num_lines):
            r = file1.readline()
            self.checkboxlist.append(QtWidgets.QCheckBox(r, self.verticalLayoutWidget))
            self.verticalLayout.addWidget(self.checkboxlist[-1])

this is how i am generating checkboxes on click of combobox.




Aucun commentaire:

Enregistrer un commentaire