I have a combox, and want to add the vaue selected in the box to a variable. The variable. I tried a few things from the documentation and was only successful on setting it to a Qlabel. Any help please
self.languageLbl = QtGui.QLabel("Download_IVR", self)
comboBox = QtGui.QComboBox(self)
comboBox.addItem("IVR_ITALY")
comboBox.addItem("IVR_FRANCE")
comboBox.addItem("IVR_SPAIN")
comboBox.addItem("IVR_GERMANY")
comboBox.move(650, 250)
comboBox.resize(150,40)
self.languageLbl.move(650,150)
comboBox.activated[str].connect(self.languageChoice)
def download_button(self):
ivrLang = self.comboBox.currentText()
I want to set ivrLang to the item selected in the combobox. Thanks!
I ended up setting ivrLang to a Qlabel. So as the QLabel is displayed, the variable is set to the text of the QLabel. That way I get the Label, and variable at the same time. Perhaps maybe not the best way to do it, but it works
You aren't connecting your signal to your callback function. You need:
And download button should look like:
Note that you still haven't done anything with that variable
irvLang
.Also it would be wise to make the comboBox and attribute of your class using
self
:EDIT: Here is a complete example that does what you seem to want.