[PyQt] Problem with a simple QDialog
Andreas Pakulat
apaku at gmx.de
Wed Nov 28 11:00:49 GMT 2007
On 28.11.07 10:40:58, Alexandre Badez wrote:
> On Nov 28, 2007 10:21 AM, Horst Herb <subscriptions at gnumed.net> wrote:
>
> > On Wednesday 28 November 2007, Alexandre Badez wrote:
> > > wChapterSelection = QtGui.QDialog()
> > > wChapterSelection.exec_()
> > >
> > > And I've got also a bus error.
> > >
> > > What really suprise me, is that I already use QDialog elsewhere, and I
> > > didn't had any problem with this.
> >
> > app = QApplication(sys.argv)
> > wChapterSelection = QtGui.QDialog()
> > wChapterSelection.show()
> > app.exec_()
> >
> > would work.
> > I am a newbie to PyQt4, so I don't know whether you can just run a widget
> > itself without creating an application first - but if you do, it works
> >
> Thanks Horst.
>
> I know it work, and I can do it as you type.
> But the problem in your exemple, is that the show is not blocking so you can
> do something like
>
> myDialog = myDialogClass()
>
> myDialog.exec_()
>
> if myDialog.result == myDialog.accept():
> # do something
> else:
> #do something else
But you can do this inside your dialog class. Just override the accept
and reject methods and do whatever logic you have their.
It doesn't make sense to have a modal dialog without another window
(i.e. in your __main__ function), as then its not really modal. And
making a modal dialog is exactly what the exec_() does.
Andreas
--
You're definitely on their list. The question to ask next is what list it is.
More information about the PyQt
mailing list