import Tkinter

richard_chamberlain richard_chamberlain at ntlworld.com
Fri Jul 28 09:48:03 EDT 2000


Hi Brian, this isn't really a Tkinter question but a general python one.

If you use the from <something> import <something or *> it imports the
contents into the current namespace.

For instance if you use:

from Tkinter import *

you can use Label or Button directly,

however if you use import Tkinter you would have to use Tkinter.Label or
Tkinter.Button.

It is considered fairly poor practice to use from * import because you're
bring everything into the current namespace. One of the exceptions to this
is GUI programming  (i.e. Tkinter or whatever) because the names used are
fairly obviously GUI related (Button,Widget,Canvas,etc.)

I suggest you get a good book,

Richard
Brian Elmegaard <be at et.dtu.dk> wrote in message
news:398186BD.60295828 at et.dtu.dk...
> Hello,
>
> I am using (trying to learn how to use) tkinter and pmw. It seems that
> something different is happening if I use
>
> import Tkinter
>
> as does in the pmw examples instead of
>
> from Tkinter import *
>
> as done in the tkinter examples.
> What is the difference?
>
> The things I have remarked are that the pmw examples does not run when
> the latter is used. They Tkinter to be defined.
> When the former is used I have to manually specify CURRENT="current" to
> be able to tag a canvas item as current. However this does not seem to
> stick to it, or perhaps I m doing something wrong.
> Also, with the former I don't seem to have access to tag_names()?
>
> Any help is appreciated,
> Brian





More information about the Python-list mailing list