[Tkinter-discuss] How to do things before Tk window creation --or--, how to perform initial window initialization correctly ?

Kenneth McDonald kmmcdonald at wisc.edu
Thu Apr 1 19:02:10 EST 2004


This came about as a result of the following specific problem,
but is something I've been wondering about for a while.

There seem to be some Tk things which don't (or shouldn't)
require an actual Tk widget instance of some sort in order to
actually call them. The 'bind' command is what's giving me
problems right now. According to the Tk docs (if I am reading
them correctly), bind creates sets of event/script pairs associated
with a string (and associated with a widget if the widget happens
to have the same name as that string) I'd like to predefine
some sets of bindings, which I can then apply to widgets
as desired. However, I just can't figure out how to call this
without using a widget! I've looked through Tkinter and tried
various things (for example, calling Misc.bind(...)), but of
course, Misc.bind wants an instance of Misc as its first
argument.) I've tried to figure out some of the things Tkinter
does internally to get around these problems, in particular
it seems to create a _default_root. However, it apparently
does this _after_ I try to create my binding sets (I know not
when), and in any case, using _default_root strikes me
as a dodgy way of doing things.

More generally, what is the "best" Tkinter way to call Tk
functions which aren't actually associated with specific
widgets. Does Tk need to create some sort of root widget
before _any_ of its functions can be called? And if so,
is there a reasonably standard way of doing this without
creating extraneous windows on the screen, or causing
problems to Tkinter programmers who might not realize
there is a "special" widget floating around.

Thanks,
Ken McDonald




More information about the Tkinter-discuss mailing list