How do you use the widgets in tkinter.ttk if you want to "import tkinter as tk"?

Terry Reedy tjreedy at udel.edu
Fri Mar 2 21:47:30 EST 2012


On 3/2/2012 8:48 PM, John Salerno wrote:
> According to the Python docs, the way to use tkinter.ttk is this:
>
> from tkinter import *
> from tkinter.ttk import *

I suppose the 'advantage' of this is that it will replace tk widgets 
with equivalent ttk widgets, if they exist and have the same name. I 
believe one has to program them differently, however, so the replacement 
cannot be transparent and one mush know anyway what gets replaced and 
what not.

> But what if I don't like this import method and prefer to do:
>
> import tkinter as tk
>
> How then do I utilize tkinter.ttk using the same name?
 > Or is that not possible? Will I have to use to separate names, like this:

No. One name for one object.

> import tkinter as tk
> import tkinter.ttk as ttk

Yes

-- 
Terry Jan Reedy




More information about the Python-list mailing list