Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #21157

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

From Terry Reedy <tjreedy@udel.edu>
Subject Re: How do you use the widgets in tkinter.ttk if you want to "import tkinter as tk"?
Date 2012-03-02 21:47 -0500
References <29015333.101.1330739333318.JavaMail.geo-discussion-forums@vbbgt10>
Newsgroups comp.lang.python
Message-ID <mailman.359.1330742876.3037.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How do you use the widgets in tkinter.ttk if you want to "import tkinter as tk"? John Salerno <johnjsal@gmail.com> - 2012-03-02 17:48 -0800
  Re: How do you use the widgets in tkinter.ttk if you want to "import tkinter as tk"? Terry Reedy <tjreedy@udel.edu> - 2012-03-02 21:47 -0500
    Re: How do you use the widgets in tkinter.ttk if you want to "import tkinter as tk"? Ben Finney <ben+python@benfinney.id.au> - 2012-03-03 14:34 +1100
    Re: How do you use the widgets in tkinter.ttk if you want to "import tkinter as tk"? John Salerno <johnjsal@gmail.com> - 2012-03-02 21:06 -0800
      Re: How do you use the widgets in tkinter.ttk if you want to "import tkinter as tk"? Rick Johnson <rantingrickjohnson@gmail.com> - 2012-03-04 17:39 -0800
        Re: How do you use the widgets in tkinter.ttk if you want to "import tkinter as tk"? Westley Martínez <anikom15@gmail.com> - 2012-03-04 18:04 -0800
        Re: How do you use the widgets in tkinter.ttk if you want to "import tkinter as tk"? John Salerno <johnjsal@gmail.com> - 2012-03-04 21:53 -0800
      Re: How do you use the widgets in tkinter.ttk if you want to "import tkinter as tk"? Kevin Walzer <kw@codebykevin.com> - 2012-03-04 20:58 -0500
    Re: How do you use the widgets in tkinter.ttk if you want to "import tkinter as tk"? John Salerno <johnjsal@gmail.com> - 2012-03-02 21:06 -0800

csiph-web