Tkinter: "Get root for a widget" is private?
Randall Hopper
aa8vb at yahoo.com
Mon Apr 3 06:43:35 EDT 2000
Fredrik Lundh:
|Randall Hopper wrote:
|> I have a widget and want to retrieve the root. I see the _root() method,
|> but by Python convention, isn't this method private?
|>
|> Should users of Tkinter be calling this?
|
|as long as nobody calls the Tkinter police, you're safe.
Well as Python doesn't have enforced data hiding, I try to honor the
conventional access rules. _<symbol> is private, an implementation detail,
and thus less likely to be present in future versions than <symbol>.
| root = widget.winfo_toplevel()
| if root.master:
| root = root.master # real root
Rob W. W. Hooft:
|Hm. Except that my Toplevel windows are often nested deeply, and
|certainly not restricted to children of the root! I think that your
|approach is distinctly different from _root() except if you severely
|restrict your toplevel window creation.
Given this it seems we should have a public root() method. Could we
add a:
root = _root
definition to Tkinter's Misc class, to make this a public feature?
Thanks,
Randall
--
Randall Hopper
aa8vb at yahoo.com
More information about the Python-list
mailing list