How to add items to a combobox in PyQt

前端 未结 3 1805
感动是毒
感动是毒 2020-12-08 19:53

I need some help adding some items to a QComboBox. So I have two comboboxes, and one populates the other depending on the item selected.

My question is

3条回答
  •  -上瘾入骨i
    2020-12-08 20:30

    I had to populate the comboBox using the names from a textfile

    Here's the code:

        names = self.classes_names()
        self.comboBox.addItems(names)
    
        def classes_names(self):
            coconames = CURRENT_DIR + os.sep + 'yolo-coco' + os.sep + 'coco.names'
            with open(coconames) as reader:
                return reader.readlines()
    

    I hope it will help someone in the future.

提交回复
热议问题