Tk Dialog Boxes

Ryan ryanmorillo at hotmail.com
Tue Dec 3 16:31:11 EST 2002


"Newt" <newt_e at blueyonder.co.uk> wrote in message news:<b_PG9.821$Qx6.8472813 at news-text.cableinet.net>...
> Hi,
> 
> I'm trying to build a class to represent a dialog box.
> 
> I've got an __init__ method that sets most of the class up, and a do_widgets
> method that defines all the widgets. The last few lines of the __init__
> metod are
> 
>         self.wstats.grab_set()
>         self.wstats.focus_set()
>         self.wstats.wait_window()
> 
> which ensures that the screen is responded to before the program continues
> any further.
> 
> I've got a couple of buttons on the dialog box which have the following code
> attatched to them:
> 
>     def bquit(self):
>         self.wstats.destroy()
>         return
> 
> The problem I have is that I want to return a value back to the calling
> program.
> 
> I thought about creating a new method which could do all the display and the
> last few lines of the __init__method, but couldn't see how that would help.
> Does the destroy() (as seen above) actually destroy the object, or could I
> set a propery on it to indicate how the form was exited?
> 
> TIA, Newt


the buttons can have a callback attached to them.  Just add a try:
finally: statement or just put in a callback before you call destroy
(I would use the try fianlly to try the callback and finally destroy
the box)



More information about the Python-list mailing list