August 5th, 2013, 07:10 AM
Help needed in Tkinter python
I am using Tkinter for gui. Actuallly I want to open a file and extract it in same folder where my file is present.
The python script is kept at some other location. Whenever I run the script and browse to my required file it extract it in folder where my script is present. Please find the attached my code.
from xml.etree import ElementTree as ET
from Tkinter import *
from tkFileDialog import askopenfilename
fname = askopenfilename(filetypes[("allfiles","*"),"pythonfiles","*.py")])
print fname main()
### unzip .fzz file
August 5th, 2013, 09:15 AM
When a python script runs, it has a "current working directory", which is where any file-level operations are going to default to; by default it's going to be the directory where the script is.
If you want to unzip these files to a specific location, you have two options:
- use os.chdir to change the current working directory to where you want these files to go.
- tack on some argument to the unzip command to specify the output location
You can determine the directory of the selected file using os.path.dirname().