On Thu, Mar 7, 2013 at 11:38 PM, Monte Milanuk <memila...@gmail.com> wrote:
> So... I've been tinkering with python and Tkinter and ttk a bit lately, and
> because I've been using pylint which complains a lot if I do a wildcard
> import like I see in many (most?) Tkinter tutorials i.e.
>
> from Tkinter import *
> from ttk import *

The tutorials are all wrong.

My advice:

Always do it this way:

    import Tkinter as tk
    import ttk

There! Now there's no global namespace pollution, and everything's
accessible. Plus, it becomes immediately clear whether you're using
ttk widgets or tkinter widgets: ttk..Button(...) or tk.Button(...).
Your code becomes more self documenting. Also, if you switch to
python3 you have to change just the imports and everything should
continue to work.

As for the constants, with this scheme you would use tk.BOTH, etc.
Personally I'm in favor of never using the constants; I see no value
in them. These things truly are constants in the underlying tk
plumbing, so you can just use the literal string "both', "n", etc
rather than the constants. There's simply no need to use a constant
named BOTH when you can use "both".  Plus, isn't "nsew" better than
N+S+E+W?
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to