[Tkinter-discuss] tkFileDialog.askopenfile() mac

Kevin Walzer kw at codebykevin.com
Wed Aug 13 04:19:20 CEST 2014


Hi,
On 8/12/14, 10:23 AM, JBB wrote:
> After some more digging, I find that Python uses the macosx backend on
> initialization.  If I change this to tk before beginning work, the
> problem goes away.  My Linux Python uses tk by default.

What do you mean by this? On Mac, Tkinter/Tk uses native dialogs and 
widgets by default. What change did you make to get it to work on the Mac?

I did see the dialog hanging on the Mac. My guess is that you weren't 
giving the event loop enough time to spin; the dialog was popping up too 
fast. This code works just fine:

from Tkinter import *
import tkFileDialog
root = Tk()
def openfile():
     tkFileDialog.askopenfilename(parent=root)
b = Button(root, text="Open", command=openfile).pack()
root.mainloop()

--Kevin

-- 
Kevin Walzer
Code by Kevin/Mobile Code by Kevin
http://www.codebykevin.com
http://www.wtmobilesoftware.com


More information about the Tkinter-discuss mailing list