python - Accessing QComboBox index values -


I have a combobox that includes 2 items - method 01, method 02 how do i get my code Do you want to tell Method01Func to Method01 , similar to Method02 ? When signing in to self.connect (self.exportCombo - [0] I tried to do it in code like this., [1 ] ... but I was hit by errors

There is a way to do this during calling Use the userData parameter, and pass in the context of the function you want to call.

This is a simple example: < Pre> Import CIX PyQt4 Import QtCore, QtGui def Method01Func (): Prinx 'Method 1' def Method02Func (): Print 'Method 2' class MainWindow (QtGui.QMainWindow): def __init __ (self, original = none): Super (main window, manually) .__ init__ (original) widget = QtGui.QWidget () self.combo = QtGui.QComboBox () self.combo.addItem ('Method1', Method01Func) self.combo.addItem ('Method2', Method02Func) self.combo.currentIndexChanged.connect (auto. Execute_method) layout = QtGui.QVBoxLayout (widget) layout.addWidget (self.combo) self.setCentralWidget (widget) @ QtCore.pyqtSlot (integer) DRF execution_math (auto, index): method = self.combo.itemData (index). ToPyObject () method () AP = QtGui.QApplication (sys.argv) window = main window () window.show () app.exec _ () ​​

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -