I have a simple problem that I cant find the solution. I have a menu item
to open a file which has a command "openfile". I would like to activate
"tkFileDialog.askopenfilename" to get the name of the file. This requires
"parent=root" or something like that for the position of the message box.
How do I pass "root" into openfile?
Thanks
Gordon Williams
def openfile():
print "opening file"
fileName=tkFileDialog.askopenfilename(parent=root, title="Open")
if fileName: #checks for cancel
print fileName #name of file to open
file=open(fileName, 'r')
read='junk' #initialize read with something
while read != "":
read=file.readline()
print "number1",read[0:-1] # strips off line return character
# This has one more line than needed due to EOF line.
# Will use seek() to move to 2nd line
print "number of bytes ",file.tell()
file.close()
to open a file which has a command "openfile". I would like to activate
"tkFileDialog.askopenfilename" to get the name of the file. This requires
"parent=root" or something like that for the position of the message box.
How do I pass "root" into openfile?
Thanks
Gordon Williams
def openfile():
print "opening file"
fileName=tkFileDialog.askopenfilename(parent=root, title="Open")
if fileName: #checks for cancel
print fileName #name of file to open
file=open(fileName, 'r')
read='junk' #initialize read with something
while read != "":
read=file.readline()
print "number1",read[0:-1] # strips off line return character
# This has one more line than needed due to EOF line.
# Will use seek() to move to 2nd line
print "number of bytes ",file.tell()
file.close()