tkFileDialog closes main application

Eric Brunel eric_brunel at despammed.com
Fri Dec 22 03:20:49 EST 2006


On Thu, 21 Dec 2006 22:37:37 +0100, James Stroud <jstroud at mbi.ucla.edu>  
wrote:

> Eric Brunel wrote:
>> BTW, why do you create a sub-class of Frame for your application? Why  
>> not  create a sub-class of Tk instead?
>>
>
> The short answer is that inhereting from Frame will allow embedding of  
> the application in another application. A Tk() can not be embedded like  
> this. Tk is appropriately instantiated if (and only if) __name__ ==  
> "__main__" here, allowing the App to run as the "main" application here.

So I rephrase my question: will this application ever need to be embedded  
into another one?

There are problems with this way of doing things, especially with menus:  
if you have to define a menu bar, you just can't attach it to a Frame; you  
have to have a Tk or Toplevel instance. So basically you're stuck: you  
can't make your application embeddable anymore. So if you actually need to  
have a graphical component / mega-widget that has a chance to be embedded  
in something else, sub-classing Frame is the way to go. If you don't,  
you'll have far less trouble if you sub-class Tk or Toplevel.
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"



More information about the Python-list mailing list