[PyKDE] More QWidget queries.

Dave S eric3 at pusspaws.net
Wed Sep 13 23:06:33 BST 2006


On Wednesday 13 September 2006 22:02, Andreas Pakulat wrote:
> On 13.09.06 21:26:51, Dave S wrote:
> > I now have my widget appearing on screen in a modal fashion thanks to
> > Andreas
> >
> > f1 = form1(self)
> > if f1.exec() == QDialog.Accepted:
> > 	script ...
> > else:
> > 	script ...
> >
> > However this only allows the communication of two states from the widget,
> > either accept() or close() so I can only really have an OK button
> > (accept) and a quit button (close).
> >
> > Is there a way to signal a third state for a third button ? My GUI would
> > be far more logical if it were possible.
>
> Not in the way above. For that to happen you'd need to connect each
> button to a separate slot. Inside the slots you set a member variable
> which reflects the button that was pressed (i.e. an int with values
> 0,1,2 depending on the button) and just call close() after that. This
> will close the dialog. When calling the dialog you just do:
>
> f1.exec()

when you say .exec() you mean .exec_loop() ? 


>
> without any if's around it. Following that you can check the value of
> the member variable
>
> if f1.buttonPressed == 0:
>   script_for_ok_button
> else if f1.buttonPressed == 1:
>   script_for_cancel_button
> ...
>
> Andreas




More information about the PyQt mailing list