Thread: ZipFile Issues

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

    Join Date
    Dec 2003
    Posts
    72
    Rep Power
    12

    ZipFile Issues


    Hi I created a zip program and wanted to know how I can use the default filename as the zipfile name I am using a tkinter GUI

    I was also wondering how I can extract all the contents of a zip file using the askopenfilename to get the file

    Here is my code to zip

    Any help is appreciated


    Code:
        def zipbCom(self):
            try:
                filetozip = askopenfilename(filetypes=[("allfiles", "*")])
                zip = zipfile.ZipFile(filetozip.join('.zip'), "w")
                self.textbox.insert(END, "Now Zipping file.zip\n")
                zip.write(filetozip)
                self.textbox.insert(END, "File Zipped\n")
                zip.close()
                self.textbox.insert(END, "Now Closed\n")
            except:
                self.textbox.insert(END, "Failed zipping file\n")
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    72
    Rep Power
    12

    Sorry


    I posted the code I was working on

    here is the code that works

    Code:
        def zipbCom(self):
            try:
                filetozip = askopenfilename(filetypes=[("allfiles", "*")])
                zip = zipfile.ZipFile('File.zip', "w")
                self.textbox.insert(END, "Now Zipping file.zip\n")
                zip.write(filetozip)
                self.textbox.insert(END, "File Zipped\n")
                zip.close()
                self.textbox.insert(END, "Now Closed\n")
            except:
                self.textbox.insert(END, "Failed zipping file\n")

IMN logo majestic logo threadwatch logo seochat tools logo