1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Rep Power

    Help needed in Tkinter python

    Hi Friends,

    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.

    import subprocess 
    import os 
    from xml.etree import ElementTree as ET 
    from Tkinter import * 
    from tkFileDialog import askopenfilename  
    def main():          
       global fname         	
       fname =     askopenfilename(filetypes[("allfiles","*"),"pythonfiles","*.py")])  
       print fname   main() 	  
    ### unzip .fzz file 
    subprocess.call(["unzip" ,fname])
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Rep Power
    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().

IMN logo majestic logo threadwatch logo seochat tools logo