Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Populate QComboBox with a list

I'm developing a GUI dialog using PyQT4 which imports some data into a Pandas DataFrame and then plots the data to an embedded Matplotlib canvas.

I'd like to pass a list of variable from the DataFrame to the combo box. My first attempt was:

list = list(df.parameter,unique())
self.FirstComboBox = QtGui.QComboBox()
self.FirstComboBox.addItems(list)

But on running this I get

TypeError: QComboBox.addItems(QStringList): argument 1 has unexpected type 'list'

I've seen examples where a sorted list of dict keys is passed to a combo box, so I'm confused that I can't pass a list.

Ben

like image 541
BMichell Avatar asked Mar 30 '16 14:03

BMichell


1 Answers

In the end I got this to work. But I'm not happy with it.

        for i in range(len(channels)):
            self.MyComboBox.addItem(channels[i])
like image 167
BMichell Avatar answered Sep 18 '22 01:09

BMichell