2

I'm working on learning to make GUIs with Tkinter for Python programs and I have run into a bunch of problems:

Attempting to run from Tkinter import filedialog I get ImportError: cannot import name filedialog. Elsewhere I have seen it called with the lowercase tkinter (which I think is for Python 3 only) but it does not recognize that as existing ImportError: No module named tkinter. Yet running from Tkinter import * works and I'm able to create the sample hello world from the tutorial.

My only guess is that it is attempting to use an obsolete version of Tkinter that shipped with OSX. Yet considering how new Mountain Lion is, I have to wonder how obsolete it would really be. My assumption is that upon installing Python 2.7 myself, if I run from IDLE, it should work, but instead I get exactly the same thing above from the IDLE shell.

So after that I tried sudo pip install tkinter and sudo pip install Tkinter from the Unix terminal, but I get back No distributions at all found for update

So I start looking into documentation on Tkinter itself, and I come across Tcl/Tk instructions for Mac OS X which states:

Important: If you are using Mac OS X 10.8, 10.7 or 10.6, use IDLE or tkinter from a 64-bit/32-bit Python installer only with ActiveTcl 8.5 installed. If you cannot install ActiveTcl 8.5, use a 32-bit-only installer instead.

So I find my OS in the table they provide and see that they recommend ActiveTcl8.5.11, but unfortunately, the download link is broken.

So I'm completely at a loss here. Any help would be appreciated.

Ben Mordecai
  • 685
  • 2
  • 8
  • 19

1 Answers1

3

If you want to implement a File Dialog, have a look at tkFileDialog. It is a seperate module & not part of Tkinter module.

You can use it by directly importing it:

import tkFileDialog
Bharat
  • 2,960
  • 2
  • 38
  • 57
  • Thanks, I was able to get something to work, but I don't really understand it. I was looking at [this question](http://stackoverflow.com/questions/9239514/filedialog-tkinter-and-opening-files) where filedialog is used as if it is a part of tkinter itself. – Ben Mordecai Dec 22 '12 at 05:16
  • 2
    They've seem to have made changes to Tkinter in Pyton 3, like making it all lower case and making tkfiledialog part of tkinter module. That's the cause of confusion. I am still using 2.x :) – Bharat Dec 22 '12 at 05:23