Python Noob, open file dialog

cutey Love cuteywithlove at gmail.com
Tue Jun 17 12:49:40 EDT 2014


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?

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()



More information about the Python-list mailing list