Tkinter: problems running as a script.
Aaron Ginn
aaron.ginn at motorola.com
Mon Jun 26 14:10:37 EDT 2000
I'm unable to run a simple "Hello, world" python script, but I
can run the script if I paste the lines one at a time into the
python interpreter. Here's the script called Tkinter.py:
#! /home/ginn/python_tk/bin/python
from Tkinter import *
root = Tk()
w = Label(root, text="Hello, world!")
w.pack()
root.mainloop()
When I run the script, I get the following output:
coronado <213> ~/bin/Tkinter.py
Traceback (innermost last):
File "/home/ginn/bin/Tkinter.py", line 2, in ?
from Tkinter import *
File "/home/ginn/bin/Tkinter.py", line 4, in ?
root = Tk()
NameError: Tk
However, when I run the script from the interpreter, it works. Here's
the output from that:
coronado <216> /home/ginn/python_tk/bin/python
Python 1.5.2 (#14, Jun 26 2000, 10:29:29) [GCC 2.95 19990728 (release)] on sunos5
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> from Tkinter import *
>>> root = Tk()
>>> w = Label(root, text="Hello, world!")
>>> w.pack()
>>> root.mainloop()
The widget pops up just as expected.
What am I doing wrong here?
Thanks,
Aaron Ginn
More information about the Python-list
mailing list