2

To allow my users to choose a file I'm using tkinter's askopenfilename. The function works fine, but after opening a file or pressing cancel the file open window goes empty and just stays open. The rest of the program moves forward correctly but even once the program ends the window remains open. And I'm not getting any errors. Is there anyone else who has experienced this behavior and has a solution? Alternatively, do you know any other easy methods of implementing a GUI file open prompt?

here's a pertinent example:

from Tkinter import Tk
from tkFileDialog import askopenfilename

Tk().withdraw() 
filename = askopenfilename() 
print(filename) 
grebnesor
  • 21
  • 2
  • Is that _actual_ code? – Bryan Oakley Apr 28 '14 at 22:58
  • yes it is. that's just a basic demonstration of the filedialog functionality I'm looking for. This gives me the same behavior as when i run my fully developed program. – grebnesor Apr 28 '14 at 23:19
  • The above code exactly as written works for me on a Macintosh. What platform are you running this on? – Bryan Oakley Apr 29 '14 at 00:03
  • Also,working on Windows as well. The problem may be somewhere in the rest of your code. Because this piece of code is working fine – Alok Apr 29 '14 at 03:17
  • I've tried running the same code on different machines and it does in fact work. The problem isn't with the rest of the code because this as written also results in a hanging window. I've also now tried running the file from my terminal and it works fine. I think the issue may be canopy. ps. I'm running on a mac – grebnesor Apr 29 '14 at 03:44
  • Are you using pylab in your code and maybe showing pictures? This could be the problem... – toti08 Feb 10 '16 at 08:10
  • This article should solve your problem: https://support.enthought.com/entries/21793229-Using-Tkinter-Turtle-in-Canopy-s-IPython-panel – Jonathan March Apr 29 '14 at 18:48

0 Answers0