[Tkinter-discuss] Fwd: LabelFrame question: UPDATE

Michael Lange klappnase at web.de
Tue Feb 28 22:24:04 CET 2012


Hi,

Thus spoketh Lynn Oliver <raycores at gmail.com> 
unto us on Tue, 28 Feb 2012 12:51:36 -0800:

> My apologies, but on further investigation I discovered that the
> problem is solved if I put  "Tkinter import " after "from ttk import "
> it works. 
> 
> The order was wrong in the main routine, but it seems that importing
> another module that imports Tkinter will fix the conflict.
> 
> 

I have not read the whole thread, so I am not sure if this actually was
the root of your problem, but if you do:

from Tkinter import *
from ttk import *

of course the LabelFrame class imported from ttk will override the one
that came from Tkinter! You can easily verify this from a shell:

$ python
Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from Tkinter import *
>>> LabelFrame
<class Tkinter.LabelFrame at 0xf708bbfc>
>>> from ttk import *
>>> LabelFrame
<class ttk.Labelframe at 0xf62eb89c>
>>> 


So while it is generally considered to be save to
do "from Tkinter import *" I would strongly recommend to prefer "import
ttk" to "from ttk import *" in order to avoid namespace confusion.

Regards

Michael


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

Men of peace usually are [brave].
		-- Spock, "The Savage Curtain", stardate 5906.5


More information about the Tkinter-discuss mailing list