Python Pyqt QComboBox show options
<p>I am trying to create a GUI with button, text box and combo box. I have problems with the combo box. I can create it but once I click on it it does not display the options. I am not getting any error which makes me hard to find the problem. This is the code so far:</p>

<pre><code>from PyQt4.QtGui import *
from PyQt4 import  QtGui
import sys

class Window(QtGui.QMainWindow,QWidget):

    def __init__(self):
        super(Window, self).__init__()
        self.setGeometry(500, 5, 1100, 1000)
        self.setWindowTitle("FourC Analyser")
        self.app = QtGui.QApplication([])
        self.app.setStyleSheet('QMainWindow{background-color: rgb(49,79,79);border: 1px solid black;}')


        extractAction = QtGui.QAction("&amp;GET TO THE CHOPPAH!!!", self)
        extractAction.setShortcut("Ctrl+Q")
        extractAction.setStatusTip('Leave The App')
        self.home()

    def home(self):
        labelCol1= 'color: rgb(255,250,205)'
        textboxCol1=("QLineEdit {background-color: rgb(49,79,79); color: rgb(218,165,32);}")

        #label
        self.lbl_project = QtGui.QLabel('Project Name', self)
        self.lbl_project.move(20, 120)
        self.lbl_project.setStyleSheet(labelCol1)

        #text box
        self.textbox = QtGui.QLineEdit(self)
        self.textbox.move(20, 150)
        self.textbox.resize(280,30)
        self.textbox.setStyleSheet(textboxCol1)

        #Combo box
        self.cb=QtGui.QComboBox(self)
        self.cb = QComboBox()
        self.cb.addItems(["1","2","3"])


    def selectionchange(self,i):
        print "Items in the list are :"
        for count in range(self.cb.count()):
            print self.cb.itemText(count)
        print "Current index",i,"selection changed ",self.cb.currentText()

def run():
    app = QtGui.QApplication(sys.argv)
    GUI = Window()
    GUI.show()
    sys.exit(app.exec_())
run()
</code></pre>

<p>You are redefining <code>self.cb</code> here:</p>

<pre><code>self.cb = QComboBox()
</code></pre>

<p>By removing this line it works for me.<br>
Both definitions work because of are your <code>import</code> statements. With <code>from PyQt4.QtGui import *</code> you import everythin within the module <code>QtGui</code> and with <code>from PyQt4 import  QtGui</code> you import the module <code>QtGui</code> itself. I recommend to remove <code>from PyQt4.QtGui import *</code>.</p>

python pyqt