Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
584 views
in Technique[技术] by (71.8m points)

events - Problem with combobox, it didn't load de options (pyqt5)

I have a program that when I press a pushbutton it loads the options of my combombox, I have three, but for a unknown reason only two works. This function read a .txt file, and then put the strings in the combobox. I tried with addItem() and addItems(), made function again and it didn't work. The function read another two combobox and then loads the options.This is the function:

def cargar_combobox_flujos2(self,event):    
    anho = int(self.ui.combobox_anho.itemText(self.ui.combobox_anho.currentIndex()))
    mes_input = self.ui.combobox_mes.itemText(self.ui.combobox_mes.currentIndex())
    dic = {'Enero': 1, 'Febrero': 2, 'Marzo': 3, 'Abril': 4, 'Junio': 5, 'Julio': 7, 'Agosto': 8, 'Septiembre': 9,
           'Octubre': 10, 'Noviembre': 11, 'Diciembre': 12}
    mes = int(dic.get(mes_input))
    lista_ssee=[]
    nombre_txt='Graficos Flujos/lista_cbbx_'+str(anho)+'_'+str(mes)+'.txt'
    if os.path.isfile(nombre_txt)==True:
        archivo = open(nombre_txt, 'r')
        c=archivo.read()
        lista=c.split(',')
        for i in lista:
            lista_ssee.append(i)
        archivo.close()
   option_barras= self.ui.comboBox_barras_CMg2.count()
   if option_barras > 1:
        self.ui.comboBox_barras_CMg2.clear()
   for barra in lista_ssee:
        self.ui.comboBox_barras_CMg2.addItems(barra)
question from:https://stackoverflow.com/questions/65921367/problem-with-combobox-it-didnt-load-de-options-pyqt5

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...