[newbie] struggling wth tkinter

Jean Dubois jeandubois314 at gmail.com
Sun Dec 8 08:40:19 CET 2013


Op zaterdag 7 december 2013 19:12:50 UTC+1 schreef Dave Angel:
> On Sat, 7 Dec 2013 08:52:08 -0800 (PST), Jean Dubois 
> 
> <jeandubois314 at gmail.com> wrote:
> 
> > I'm trying to go through a tutorial on tkinter which has the code 
> 
> below as an example. The only thing I see when running it is a little 
> 
> popup with "Click mouse here to quit" which works as expected but 
> 
> always shows the following error-message.
> 
> > However the "main" window which should let you enter the numbers is 
> 
> not shown.
> 
> > This is the quit error message:
> 
> > Traceback (most recent call last):
> 
> >   File "./feet2meters.py", line 3, in <module>
> 
> >     from tkinter import ttk
> 
> > ImportError: cannot import name ttk
> 
> 
> 
> > This is the code:
> 
> > #!/usr/bin/env python
> 
> > from tkinter import *
> 
> > from tkinter import ttk
> 
> 
> 
> Thanks for supplying the complete traceback.  But you should also 
> 
> tell the python version and what OS.  I'll guess python 3.3 on Linux. 
> 
> 
> 
> 
> 
> Finally,  what version tk are you running?  These widgets were 
> 
> introduced in tk 8.5
> 
> 
> 
> Since it failed on the second import, none of the rest of the code 
> 
> matters. However, since you're not running it from a terminal window, 
> 
> it's conceivable that your ide is affecting the result.
> 
> 
> 
> -- 
> 
> DaveA

I have two pythons installed on my system:
Python 2.7.3 and Python 3.2.3
When using python2 I get the errors mentioned above
When using python3 (I removed the shebang and started as python3 feettometers.py) then I get these errors:

coolens at antec2:~$ python3 feet2meters.py 
Traceback (most recent call last):
  File "feet2meters.py", line 1, in <module>
    from tkinter import *
  File "/home/coolens/tkinter.py", line 2, in <module>
    import Tkinter as tk
ImportError: No module named Tkinter

I tried to fix this by installing
apt-get install python3-tk (python3-tk_3.2.3-1_amd64.deb)

but the error remains

What should I do now?

thanks in advance
jean



More information about the Python-list mailing list