On Fri, Mar 08, 2013 at 05:54:57AM -0600, Bryan Oakley wrote: > 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? . . . Me, too.
As much as I favor brevity, I have been consistent in my career in eschewing "from Tkinter import *" in favor of "import Tkinter ...", even though that--or because!--re- sults in the need to qualify references. My experience is that the source code which follows, and the maintain- ers who read it, are happier. I so strongly believe this that I'm tempted to initiate a project to reform, or at least counteract, the "many (most?) Tkinter tutorials". [The problem is that following through would mean more neglect of PyPDF2 and ..., where I'm *really* needed.] _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org http://mail.python.org/mailman/listinfo/tkinter-discuss