PyQt signals/slots dialogs question

AlienBaby matt.j.warren at gmail.com
Mon Jun 7 14:21:26 EDT 2010


On Jun 7, 5:21 pm, AlienBaby <matt.j.war... at gmail.com> wrote:
> My real aim here is to learn pyqt, so I would rather not the the
> QWizard process until I understand myself whats going on behind the
> scenes.

Perhaps I posted to early, but a little more perserverance and I have
managed to unthaw the brain and move forward.  I've ended up with the
following. It does what I need, and now it's working I can think
around how to implement with a better approach;


from PyQt4 import QtCore, QtGui
from WELCOME import Ui_Dialog as welcomeDialog
from SOURCE_TYPE_SELECT import Ui_Dialog as sourceTypeSelectDialog
from SOURCE_TYPE_CONFIRMATION import Ui_Dialog as
sourceTypeConfirmationDialog

..>snip<

class WelcomeDialog(QtGui.QDialog):
    def __init__(self,parent=None):
        QtGui.QWidget.__init__(self,parent)
        self.ui=welcomeDialog()
        self.ui.setupUi(self)

class SourceTypeSelect(QtGui.QDialog):
    def __init__(self,parent=None):
        QtGui.QWidget.__init__(self,parent)
        self.ui=sourceTypeSelectDialog()
        self.ui.setupUi(self)

class SourceTypeConfirmation(QtGui.QDialog):
    def __init__(self,parent=None):
        QtGui.QWidget.__init__(self,parent)
        self.ui=sourceTypeConfirmationDialog()
        self.ui.setupUi(self)


def WelcomeNext():
    welcome.hide()
    sourceTypeSelect.show()
def WelcomeCancel():
    sys.exit()


def SourceTypeSelectNext():
    sourceTypeSelect.hide()
    for widget in
sourceTypeSelect.ui.availableChoices.findChildren(QtGui.QWidget):
        if widget.isChecked():
            print widget.text()
 
sourceTypeConfirmation.ui.selectedSourceType.setText(widget.text())
    sourceTypeConfirmation.show()
def SourceTypeSelectCancel():
    sys.exit()


def SourceTypeConfirmationBack():
    sourceTypeConfirmation.hide()
    sourceTypeSelect.show()


if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)

    #Instance dialogs and connect buttons
    welcome=WelcomeDialog()
 
welcome.ui.welcomeNext.connect(welcome.ui.welcomeNext,QtCore.SIGNAL("clicked()"),WelcomeNext)
 
welcome.ui.welcomeCancel.connect(welcome.ui.welcomeCancel,QtCore.SIGNAL("clicked()"),WelcomeCancel)


    sourceTypeSelect=SourceTypeSelect()
 
sourceTypeSelect.ui.sourceTypeSelectNext.connect(sourceTypeSelect.ui.sourceTypeSelectNext,QtCore.SIGNAL("clicked()"),SourceTypeSelectNext)
 
sourceTypeSelect.ui.sourceTypeSelectCancel.connect(sourceTypeSelect.ui.sourceTypeSelectCancel,QtCore.SIGNAL("clicked()"),SourceTypeSelectCancel)


    sourceTypeConfirmation=SourceTypeConfirmation()
 
sourceTypeConfirmation.ui.sourceTypeConfirmationBack.connect(sourceTypeConfirmation.ui.sourceTypeConfirmationBack,QtCore.SIGNAL("clicked()"),SourceTypeConfirmationBack)


    welcome.show()
    sys.exit(app.exec_())







More information about the Python-list mailing list