Skip to content Skip to sidebar Skip to footer

Displaying Two Values In A Pyqt5 Combobox And Passing Those Values

Currently I have two combo boxes, one contains a sitecode the other a folder, these are read in from a csv which has two columns SITECODE and FOLDER. Any row contains these two rel

Solution 1:

Just add items using a tuple:

tuples = job_list[['SITECODE', 'FOLDER']]for row in tuples.itertuples():
    self.combo.addItem('{} | {}'.format(row.SITECODE, row.FOLDER), (row.SITECODE, row.FOLDER))
self.combo.currentIndexChanged.connect(self.comboChanged)

Then access the item data likewise:

defcomboChanged(self, index):
    code, folder = self.combo.itemData(index)
    # ...

Post a Comment for "Displaying Two Values In A Pyqt5 Combobox And Passing Those Values"