Re: import of ttk

Discussion in 'Python' started by Terry Reedy, Jan 5, 2013.

  1. Terry Reedy

    Terry Reedy Guest

    On 1/5/2013 2:21 PM, Verde Denim wrote:
    > On 01/04/2013 11:39 PM, Terry Reedy wrote:
    >> On 1/4/2013 11:02 PM, Verde Denim wrote:
    >>> In reading through one of the learning articles, I have a bit of code
    >>> that imports ttk, but I apparently don't have this installed. I've
    >>> looked up the svn checkout for python-tk, and have checked it out
    >>> (read-only), but still get the same error. I'm running 2.6.6 python, if
    >>> that helps.


    Upgrade to the latest 2.7 or even 3.3 if at all possible.

    >> Show the line of code that did not work and the traceback. What system
    >> are you running on and what tcl/tk installation does it have? ttk is
    >> included with any 8.5 installation. tile is often included with 8.4
    >> installations and should be picked up as well.
    >>
    >> The article I'm looking at is here -
    >>> http://www.zetcode.com/gui/tkinter/introduction/

    >>
    >>

    > The line is -
    > 16 from ttk import Frame, Button, Style
    >
    > $ python tkinter_tut1.py
    > Traceback (most recent call last):
    > File "tkinter_tut1.py", line 16, in <module>
    > from ttk import Frame, Button, Style
    > ImportError: No module named ttk
    >
    > I'm running on Debian Squeeze, and do show both 8.4 and 8.5 of tcl


    On my Windows 2.7 installation, directory /Lib contains directory
    /lib-tk (which is added to the path). /lib-tk contains files Tkinter.py
    and ttk.py, among others. If you have ttk.py, then I do not think you
    should get that specific message; if there were a problem finding
    tcl/tk, it should say something else. If you do not have that file, as
    it seems, then your installation is incomplete. So check your
    /Lib/lib-tk. If you do not know where it is

    import sys
    print(sys.path)

    Portability note: In 3.x, /lib-tk was renamed /tkinter and removed from
    the path. Tkinter.py was renamed __init__.py to make the renamed
    /tkinter an importable package. So 'import Tkinter becomes 'import
    tkinter', while 'import ttk', etcetera, is now 'import tkinter.ttk',
    etcetera. 2to3 should make the fixes.

    --
    Terry Jan Reedy
    Terry Reedy, Jan 5, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert Hicks

    New Tk look (aka Ttk or Tile widgets)

    Robert Hicks, Jan 10, 2008, in forum: Python
    Replies:
    3
    Views:
    303
    Robert Hicks
    Jan 10, 2008
  2. Peter

    ttk styles

    Peter, Mar 14, 2011, in forum: Python
    Replies:
    6
    Views:
    1,020
    Peter
    Mar 21, 2011
  3. Verde Denim

    import of ttk

    Verde Denim, Jan 5, 2013, in forum: Python
    Replies:
    0
    Views:
    105
    Verde Denim
    Jan 5, 2013
  4. Terry Reedy

    Re: import of ttk

    Terry Reedy, Jan 5, 2013, in forum: Python
    Replies:
    0
    Views:
    129
    Terry Reedy
    Jan 5, 2013
  5. Verde Denim

    Re: import of ttk

    Verde Denim, Jan 5, 2013, in forum: Python
    Replies:
    0
    Views:
    147
    Verde Denim
    Jan 5, 2013
Loading...

Share This Page