By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,932 Members | 1,944 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,932 IT Pros & Developers. It's quick & easy.

OS X and Tkinter

P: n/a
I recently purchased a book to learn python, and am at a part where I
want to start working with GUIs. I have an OS X system, and am using
the default python installed on the system. I have installed Tcl/Tk
Aqua from http://tcltkaqua.sourceforge.net/.

When I run the file called gui.py that contains this:

from Tkinter import *
root = Tk()
root.title("Simple GUI")
root.geometry("200x100")

I get this back:

python gui.py
Traceback (most recent call last):
File "gui.py", line 1, in ?
from Tkinter import *
File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/lib-tk/Tkinter.py", line 38, in ?
import _tkinter # If this fails your Python may not be configured
for Tk
ImportError: No module named _tkinter

I have looked everywhere on the net, and can't figure out how to
configure python so that Tkinter will work with it. Any help would be
appreciated.
Mike

Jul 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Mike Tuller wrote:
I recently purchased a book to learn python, and am at a part where I
want to start working with GUIs. I have an OS X system, and am using
the default python installed on the system. I have installed Tcl/Tk
Aqua from http://tcltkaqua.sourceforge.net/.


Download and install

http://www.pythonmac.org/packages/Ma...macosx10.3.zip

It will install the _tkinter extension module.

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
Jul 18 '05 #2

P: n/a
Robert Kern wrote:
Mike Tuller wrote:
I recently purchased a book to learn python, and am at a part where I
want to start working with GUIs. I have an OS X system, and am using
the default python installed on the system. I have installed Tcl/Tk
Aqua from http://tcltkaqua.sourceforge.net/.

Download and install

http://www.pythonmac.org/packages/Ma...macosx10.3.zip


Oops! Wrong one.

http://www.pythonmac.org/packages/_t...macosx10.3.zip

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
Jul 18 '05 #3

P: n/a
>>>>> Mike Tuller <py****@discovercommunityed.com> (MT) wrote:
MT> I recently purchased a book to learn python, and am at a part where I want
MT> to start working with GUIs. I have an OS X system, and am using the
MT> default python installed on the system. I have installed Tcl/Tk Aqua from
MT> http://tcltkaqua.sourceforge.net/. MT> When I run the file called gui.py that contains this: MT> from Tkinter import *
MT> root = Tk()
MT> root.title("Simple GUI")
MT> root.geometry("200x100") MT> I get this back: MT> python gui.py
MT> Traceback (most recent call last):
MT> File "gui.py", line 1, in ?
MT> from Tkinter import *
MT> File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
MT> python2.3/lib-tk/Tkinter.py", line 38, in ?
MT> import _tkinter # If this fails your Python may not be configured for
MT> Tk
MT> ImportError: No module named _tkinter MT> I have looked everywhere on the net, and can't figure out how to configure
MT> python so that Tkinter will work with it. Any help would be appreciated.


You need to install Tkinter. The easiest way is to use the Python Package
Manager: http://www.python.org/packman/
--
Piet van Oostrum <pi**@cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: pi**@vanoostrum.org
Jul 18 '05 #4

P: n/a
Mike Tuller wrote:
I have looked everywhere on the net, and can't figure out how to
configure python so that Tkinter will work with it. Any help would be
appreciated.


The following worked for me with OSX version 10.3 and the default python
2.3:

http://www.pythonmac.org/wiki/FAQ#he...71cd2e856e81e3

"
5.5 How do I install Tkinter? How do I get IDLE to work?

Here are the steps for installing Tkinter:
Download and install TclTkAqua
Download and install the MacPythonPantherAddons if you are using
the version of Python 2.3 included with OS X 10.3
Open PackageManager, it is located in /Applications/MacPython-2.3
Install _tkinter

You may then use Tkinter based applications such as IDLE, which should
also be available from PackageManager. Note that if you are running any
sort of GUI application from Terminal, you must use "pythonw" not
"python" to launch the script.

If the PackageManager complains that it cannot open a certain URL at
www.python.org, choose "Open URL" from the "File" menu and open
http://www.python.org/packman/versio...acintosh.plist
instead of the standard URL.
"
Jul 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.