[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyKDE] QDialog and multiple buttons
From: "Roberto Alsina" <ralsina () kde ! org>
Date: 2005-08-02 14:42:22
Message-ID: 60076.24.232.127.13.1122995006.squirrel () linux ! netline ! com ! ar
[Download RAW message or body]
> Hi,
>
> I would like to create a dialog with three buttons: 'Heads', 'Tails',
> and 'Cancel'. If I only had the 'Heads' and 'Tails' buttons then my
> life would be easy. I would just connect the 'Heads' button up to the
> accept() slot and connect the 'Tails' button up to the reject() slot.
> What do I do with the 'Cancel' button? Is there a way to detect which
> button was clicked and modify the result so exec_loop() returns
> something other than Accepted or Rejected? Is there a better way of
> doing this?
Create a heads slot, and a tails slot.
def heads(self):
self.head=True
self.accept()
def tails(self):
self.head=False
self.accept()
When you exec_loop the dialog, first test what it returns, then use
dialog.head
It's a bit longer, but it is way cleaner, because you are not overloading
cancel(), which should mean "do nothing" with a meaning it doesn't usually
have.
Another idea is to use radio buttons showing head/tails and then use
regular accept/cancel buttons.
--
("\''/").__..-''"`-. . Roberto Alsina
`9_ 9 ) `-. ( ).`-._.`) ralsina@kde.org
(_Y_.)' ._ ) `._`. " -.-' KDE Developer (MFCH)
_..`-'_..-_/ /-'_.'
(l)-'' ((i).' ((!.' Buenos Aires - Argentina
Imminentizing the eschaton since 1971.
_______________________________________________
PyKDE mailing list PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic