- Joined
- Jun 17, 2011
- Messages
- 1
- Reaction score
- 0
I'm having some trouble with my script at the moment. I'm writing a program to bring up a dialog box to ask for the file, which works fine, then, using os.popen(<filename>) to open the file selected in a separate window. However, when I use the two together, as shown below, the os.popen doesn't run. But, if I just run os.popen('dir\\test.txt'), then the file will open properly.
####################################
import os
import tkFileDialog as fileOpen
from Tkinter import *
os.popen('D:\\test.txt') ## this bit works perfectly fine
def askOpen():
path = fileOpen.askopenfilename(title='Spreadsheet to open',initialdir='somedirectory',parent=root,filetypes=[('text docs','.txt'),('Excel Spreadsheets','.xls')]) ## as does this
print path ##this would print "somedirectory/fileSelected", as a string, exactly the format that should work in os.popen
os.popen(path) ## but this doesn't work...??
root = Tk()
Button(root,text='Open File',command=askOpen).pack()
root.mainloop()
####################################
import os
import tkFileDialog as fileOpen
from Tkinter import *
os.popen('D:\\test.txt') ## this bit works perfectly fine
def askOpen():
path = fileOpen.askopenfilename(title='Spreadsheet to open',initialdir='somedirectory',parent=root,filetypes=[('text docs','.txt'),('Excel Spreadsheets','.xls')]) ## as does this
print path ##this would print "somedirectory/fileSelected", as a string, exactly the format that should work in os.popen
os.popen(path) ## but this doesn't work...??
root = Tk()
Button(root,text='Open File',command=askOpen).pack()
root.mainloop()