[Tkinter-discuss] confused on grid positioning vs. imports
Michael Lange
klappnase at web.de
Fri Mar 8 10:33:08 CET 2013
Hi,
On Thu, 07 Mar 2013 21:38:52 -0800
Monte Milanuk <memilanuk at gmail.com> wrote:
(...)
>
> from Tkinter import Tk, S, E
> from ttk import Frame, Label, Button, Entry
>
> which works with the original code example, but thats where I get
> confused.
>
> I have to import Label from ttk but the sticky parameters from Tkinter?
> Pardon me for saying, but that doesn't appear to make a whole lot of
> sense at first glance. Am I getting that correct, or is there some
> other way to do it that is more correct?
>
> I'm starting to think it'd just be easier to put some tags in comments
> at the start of the file to tell pylint to disable warning me about
> wildcard imports, and just go back to using those!
you may want to have a look at the Tkconstants.py module, where all these
contants like S, N and so on are defined. If you do
from Tkinter import *
all of these are added to the namespace automagically, however if you do
import Tkinter
the constants have to be either addressed by Tkinter.S etc. *or* (and
that is what I would recommend) you can simply use the string values the
constants represent, like "s" for S, "left" for LEFT and so on, as in
labelCel.grid(row=1, column=1, sticky="se")
Regards
Michael
.-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-.
Witch! Witch! They'll burn ya!
-- Hag, "Tomorrow is Yesterday", stardate unknown
More information about the Tkinter-discuss
mailing list