Python Noob, open file dialog

alister alister.nospam.ware at ntlworld.com
Wed Jun 18 04:32:40 EDT 2014


On Wed, 18 Jun 2014 00:36:29 -0700, cutey Love wrote:

> No it's still paused after selection and only excutes when the window is
> closed.
> 
> On Tuesday, June 17, 2014 6:34:41 PM UTC+1, MRAB wrote:
>> On 2014-06-17 17:49, cutey Love wrote:
>> 
>> > My first attempt at Python,
>> > I'm using Tkinter and all is going well except when I'm using
>> >      file_path = tkFileDialog.askopenfilename()
>> >      print "test"
>> >
>> > opens great and lets me select a file, the problem is it then pauses?
>> > instead of continuing with the function? until I close, then it goes
>> > and completes the function?
>> >
>> > Why is this and how do I fix it?
>> >
>> It's waiting for you to click the Open button to confirm your
>> 
>> selection. That's normal behaviour for such a dialog box.
>> 
>> > Full code
>> >
>> > import Tkinter, tkFileDialog
>> >
>> > from Tkinter import *
>> >
>> > emails = []
>> >
>> > def askFile():
>> 
>> >      file_path = tkFileDialog.askopenfilename()
>> 
>> >      print "test"
>> >
>> 
>> >
>> > window = Tkinter.Tk()
>> 
>> > window.title("Super Star")
>> >
>> > window.geometry("600x600")
>> >
>> > menubar = Menu(window)
>> 
>> > filemenu = Menu(menubar, tearoff=0)
>> 
>> > filemenu.add_command(label="New", command=askFile)
>> 
>> 
>> >
>> > menubar.add_cascade(label="File", menu=filemenu)
>> >
>> > window.config(menu=menubar)
>> >
>> > window.mainloop()

I have just tested your sample code & it works fine for me.

Fedora 20
Python 2.7.5

What is your environment

Please also see the various comments regarding top posting & google groups




-- 
Are you scared of speed?  If so, then try Windows 95.



More information about the Python-list mailing list