PyQt signals/slots dialogs question

AlienBaby matt.j.warren at gmail.com
Mon Jun 7 12:17:50 EDT 2010


On Jun 7, 4:37 pm, Phil Thompson <p... at riverbankcomputing.com> wrote:
> On Mon, 7 Jun 2010 08:22:07 -0700 (PDT), AlienBaby
> <matt.j.war... at gmail.com>
> wrote:
>
>
>
>
>
> > Hi,
>
> > I'm just starting to get to grips with PyQt, and I'm having a bit of
> > trouble connecting slots / signals, or understanding how I should do
> > so to achieve what I am after.
>
> > I am trying to write an application that will display a sequence of
> > dialogs, with back / next / cancel buttons to step through the
> > dialogs. Each dialog will capture user input, ask the user to browse
> > for a file, present some radio-buttons for a selection etc..
>
> > I've put the dialogs together in Designer, and I come to startup the
> > app with a small piece of python code, create an instance of each
> > dialog, and then connect up the buttons to any methods needed to
> > control the movement through the dialogs etc.
>
> > I'm having a brain-freeze though, and just can't figure out what I
> > should be doing next, or the best approach to take.
>
> > for example, Currently I am thinking I would need to connect the
> > clicked() signal of the Next button on dialog 1 to a method say,
> > 'dialog1Next' that would then hide dialog1 and show dialog2.  I would
> > then need to connect Dialog 2's clicked() signal of its next button to
> > a method called 'dialog2Next' that hides dialog2 and shows dialog3
> > etc...
>
> > I would also, for example,  need methods for dialog2Back,
> > dialog2cancel, dialog1cancel etc..
>
> > I'm having trouble figuring out how to setup the connections, and
> > where the slot-methods should live..
>
> > I have this so far;
>
> > 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
> > from ACCEPT_EULA import Ui_Dialog as acceptEulaDialog
> > from CONFIRM_REQUIREMENTS import Ui_Dialog as
> > confirmRequirementsDialog
> > from SOURCE_BINARY_LOCATE import Ui_Dialog as sourceBinaryLocateDialog
> > from SOURCE_BINARY_PROBLEMS import Ui_Dialog as
> > sourceBinaryProblemsDialog
> > from OUTFILE_LOCATE import Ui_Dialog as outfileLocateDialog
> > from OUTFILE_PROBLEMS import Ui_Dialog as outfileProblemsDialog
> > from COLLECTION_PROGRESS import Ui_Dialog as collectionProgressDialog
> > from OUTFILE_LOCATION import Ui_Dialog as outfileLocationDialog
>
> > class StartQT4(QtGui.QDialog):
> >     def __init__(self, parent=None):
> >         QtGui.QWidget.__init__(self, parent)
> >         self.Welcome = welcomeDialog()
> >         self.Welcome.setupUi(self)
> >         self.SourceTypeSelect = sourceTypeSelectDialog()
> >         self.SourceTypeConfirmation = sourceTypeConfirmationDialog()
> >         self.AcceptEula = acceptEulaDialog()
> >         self.ConfirmRequirements=confirmRequirementsDialog()
> >         self.SourceBinaryLocate=sourceBinaryLocateDialog()
> >         self.SourceBinaryProblems=sourceBinaryProblemsDialog()
> >         self.OutfileLocate=outfileLocateDialog()
> >         self.OutfileProbelms=outfileProblemsDialog()
> >         self.CollectionProgress=collectionProgressDialog()
> >         self.OutfileLocation=outfileLocationDialog
>
> >         #Connect up next/back/cancel etc.. buttons
>
> > ???     self.Welcome.connect(self.Welcome.welcomeNext,
> > QtCore.SIGNAL("clicked()"),WelcomeNext)
>
> > def WelcomeNext():
> >         #Code here to hide Welcome dialog and show SourceTypeSelect
> > dialog
>
> > if __name__ == "__main__":
> >    app = QtGui.QApplication(sys.argv)
> >    myapp = StartQT4()
> >    myapp.show()
> >    sys.exit(app.exec_())
>
> > My questions are, am I approaching this the right way, with a method
> > per action per dialog to move through the dialogs, and just how do I
> > setup the connections I need. I'm getting confused with scope etc. IE:
> > if the connect is right, and WelcomeNext fires, how can it refer to
> > myapp.SourceTypeSelect.show() or myapp.Welcome.hide()
>
> > Any help much appreciated.
>
> Sounds like you are trying to build a wizard the hard way.
>
> Use Designer to create a QWizard with the contents of each of your dialogs
> as a QWizardPage.
>
> Phil- Hide quoted text -
>
> - Show quoted text -

Interesting idea. I shall take a look, but there is q fair amount of
work that needs to be done between dialogs, validation and other
thoings etc..  Would a QWizard help?


As well, I would like to understand the process of coding my own so I
can build other UI's also.



More information about the Python-list mailing list