开发者

Python file dialog issue

I am trying to use Tkinter to choose a file and then import that filename into an argument to pass in a function. The progra开发者_JAVA百科m simply stops after the file is chosen. I included a print statement just to see if it returns the path and it does so I am not sure why it won't work in the function.

#Main

from Tkinter import *
import tkFileDialog


fileOpen = Tk()
fileOpen.withdraw() #hiding tkinter window

file_path = tkFileDialog.askopenfilename(title="Open file", filetypes=[("txt file",".txt"),("All files",".*")])

if file_path != "":
   print "you chose file with path:", file_path

else:
   print "you didn't open anything!"

master.quit()

print file_path   


spaceParser (file_path,'r','/Users/Desktop/TygerTygerParsed.txt','w')


This (shortened version) works just fine:

from Tkinter import *
import tkFileDialog

fileOpen = Tk()
fileOpen.withdraw() #hiding tkinter window

file_path = tkFileDialog.askopenfilename(
    title="Open file", filetypes=[("txt file",".txt"),("All files",".*")])

if file_path != "":
   print "you chose file with path:", file_path

else:
   print "you didn't open anything!"

print file_path   

So I'm guessing your program is halting on

master.quit()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜