0

I want to create a combo box by clicking on a push button.

class Ui_Dialog(object):
    def setupUi(self, Dialog):
        self.Dialog=Dialog
        self.Dialog.setObjectName(_fromUtf8("Dialog"))
        self.Dialog.resize(681, 408)

        self.pushButton = QtGui.QPushButton(self.Dialog)
        self.pushButton.setGeometry(QtCore.QRect(400, 290, 75, 23))
        self.pushButton.setObjectName(_fromUtf8("pushButton"))

class Window(QtGui.QMainWindow):
    def __init__(self):
        QtGui.QMainWindow.__init__(self)
        self.ui=Ui_Dialog()
        self.ui.setupUi(self)
        self.ui.pushButton.clicked.connect(self.browse)

    def browse(self):
        self.ui.comboBox=QtGui.QComboBox(self.ui.Dialog)
        self.ui.comboBox.setObjectName(_fromUtf8("comboBox"))
        self.ui.comboBox.addItem(_fromUtf8(""))
        self.ui.comboBox.setGeometry(QtCore.QRect(100, 100, 100, 100))
if __name__ == '__main__':
    import sys
    app = QtGui.QApplication(sys.argv)
    dlg = Window()
    dlg.show()
    app.exec_()

When I run the code and click on the push button nothing happens. Am I forgetting something/going wrong somewhere?

Ryan Bemrose
  • 9,018
  • 1
  • 41
  • 54
Hamid
  • 13
  • 4

0 Answers0