[Tutor] tkinter nested class question

Alan Gauld alan.gauld at btinternet.com
Wed Feb 2 01:58:03 CET 2011


"Elwin Estle" <chrysalis_reborn at yahoo.com> wrote

> from Tkinter import *
>
> class Header_item(object):
>
>    def __init__(self, lab_text = '', lab_width = 5, ent_width = 5, 
> grid_row = 1, grid_col = 1):
>        self.container = Frame()

You haven't specified a parent object for the Frame.
I suspect the default parent will be the root object...

> class Checksheet(Frame):
>    def __init__(self, master, rows):
>        rows += 2
>        self.ck_header_frame = Frame()

And again here

Also, although you inherit from Frame you do not call
its init function leaving the parent object un initialised
- thats never a good idea in a GUI framework(nor in
any framework for that matter)

Remember that its the oparent argument that connects all the
widgets together so that the event passing etc works properly.
Creating parentless widgets is asking for problems and odd behaviour.

HTH,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list