diff --git a/README.md b/README.md index 885b65b..c802681 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Note the app creates 2 files, "tk_path_finder_config.json" and "notes.db" (sqlit - Create multiple folders at once (hit cntrl-d in the create folder window to duplicate line). - "Open with" functionality. - Open folder in explorer or command prompt. + - Unzip .zip files - Compatible with MS Teams folders. - To Do List. - Diary. @@ -66,7 +67,7 @@ pip install PyPDF2 ## Preview ![Main](images/main_image.PNG) -![alt text](https://imgur.com/trjQ4QE.png) +![Right_Click](images/right_click_menu_image.png) ![alt text](https://imgur.com/haNY5f5.png) diff --git a/images/right_click_menu_image.png b/images/right_click_menu_image.png new file mode 100644 index 0000000..cfe5c34 Binary files /dev/null and b/images/right_click_menu_image.png differ diff --git a/src/controller/controller.py b/src/controller/controller.py index 1d64753..77e27d5 100644 --- a/src/controller/controller.py +++ b/src/controller/controller.py @@ -8,6 +8,7 @@ import subprocess from subprocess import DEVNULL import threading +import zipfile from docx import Document from openpyxl import Workbook @@ -362,7 +363,8 @@ def copy_cut_file_folder(self, files, branch_id, mode, total_size_selected=None) elif mode == "copy": self.file_to_cut = None self.file_to_copy = copy.deepcopy(files) - self.view.update_clipboard_labels(len(files), total_size_selected) + + self.view.update_clipboard_labels(len(files), total_size_selected, mode) def paste_file_folder(self, branch_id): current_directory = self.model.branch_tabs[branch_id].current_directory @@ -634,4 +636,23 @@ def get_forward_and_previous_current_directories(self, branch_id): #fwd_directories, previous_directories, current_directory = self.model.branch_tabs[branch_id].get_forward_and_previous_current_directories() return self.model.branch_tabs[branch_id].get_forward_and_previous_current_directories() - #return fwd_directories, previous_directories, current_directory \ No newline at end of file + #return fwd_directories, previous_directories, current_directory + + def unzip_file(self, file_name, branch_id): + file_name_wo_extension, file_extension = os.path.splitext(file_name) + + current_directory = self.model.branch_tabs[branch_id].current_directory + source = os.path.join(current_directory, file_name) + destination = os.path.join(current_directory, file_name_wo_extension) + + if os.path.isdir(destination): + self.view.show_error(f"Cannot Extract as the Destination Folder Already Exists\n{destination}") + else: + try: + with zipfile.ZipFile(source, 'r') as zip_ref: + # Extract all the contents to the specified directory + zip_ref.extractall(destination) + self.refresh_tab(branch_id) + self.view.show_success("Successfully Extracted") + except Exception as e: + self.view.show_error(f"The Following Error Occured\n{str(e)}") \ No newline at end of file diff --git a/src/custom_widgets/branch_tab.py b/src/custom_widgets/branch_tab.py index 0b1b703..f387ead 100644 --- a/src/custom_widgets/branch_tab.py +++ b/src/custom_widgets/branch_tab.py @@ -55,7 +55,7 @@ def setup_buttons(self): ToolTip(b, text="Search", bootstyle=(INFO, INVERSE), delay=self.view.tool_top_delay) b = ttk.Button(self, text=u"\u27F3", command=lambda branch_id=self.branch_id: self.view.controller.refresh_tab(self.branch_id), style="primary.TButton") - b.grid(row=0, column=15, padx=(0, self.view.default_padx)) + b.grid(row=0, column=15, columnspan=2, sticky="E", padx=(0, self.view.default_padx)) ToolTip(b, text="Refresh", bootstyle=(INFO, INVERSE), delay=self.view.tool_top_delay) def setup_adress_bar(self): @@ -275,6 +275,9 @@ def right_click_treeview(self, event): popup_menu.add_command(label="Rename", command=lambda mode=mode, initialvalue=file_name, branch_id=self.branch_id: self.view.controller.new_edit_file_folder(mode, initialvalue, branch_id), image=self.view.rename_icon2, compound="left") + if file_extension.lower() == ".zip": + popup_menu.add_command(label="Unzip", command=lambda file_name=file_name, file_extension=file_extension, branch_id=self.branch_id: self.view.controller.unzip_file(file_name, branch_id), image=self.view.zip_icon2, compound="left") + popup_menu.add_separator() popup_menu.add_command(label="Copy Full Path to Clipboard", command= lambda file_name=file_name, branch_id=self.branch_id, mode="full":self.view.controller.copy_to_clipboard(file_name, branch_id, mode)) @@ -310,8 +313,12 @@ def right_click_treeview(self, event): for file_iid in self.treeview.selection(): selection.append(self.treeview.item(file_iid, 'text')) - popup_menu.add_command(label="Cut", command=lambda files=selection, branch_id=self.branch_id, mode="cut": self.view.controller.copy_cut_file_folder(files, branch_id, mode), image=self.view.cut_icon2, compound="left") - popup_menu.add_command(label="Copy", command=lambda files=selection, branch_id=self.branch_id, mode="copy", total_size_selected=self.total_size_selected: self.view.controller.copy_cut_file_folder(files, branch_id, mode, total_size_selected), image=self.view.copy_icon2, compound="left") + popup_menu.add_command(label="Cut", + command=lambda files=selection, branch_id=self.branch_id, mode="cut", total_size_selected=self.total_size_selected: + self.view.controller.copy_cut_file_folder(files, branch_id, mode, total_size_selected), image=self.view.cut_icon2, compound="left") + popup_menu.add_command(label="Copy", + command=lambda files=selection, branch_id=self.branch_id, mode="copy", total_size_selected=self.total_size_selected: + self.view.controller.copy_cut_file_folder(files, branch_id, mode, total_size_selected), image=self.view.copy_icon2, compound="left") if self.view.controller.file_to_copy != None or self.view.controller.file_to_cut != None: popup_menu.add_command(label="Paste", command=lambda branch_id=self.branch_id: self.view.controller.paste_file_folder(branch_id), image=self.view.paste_icon2, compound="left") diff --git a/src/main.py b/src/main.py index 432190f..76f49d9 100644 --- a/src/main.py +++ b/src/main.py @@ -35,7 +35,7 @@ def __init__(self, parent, *args, **kwargs): self.controller = controller.Controller(root, parent, self) # ----------------- VERSION ----------------------- - self.version = "0.52.0" + self.version = "0.53.0" # ----------------- WEEK NUMBER ----------------------- year, week_num, day_of_week = datetime.date.today().isocalendar() diff --git a/src/view/view.py b/src/view/view.py index 4e7770d..5e93d49 100644 --- a/src/view/view.py +++ b/src/view/view.py @@ -147,8 +147,11 @@ def delete_branch_tab(self, branch_id): self.branch_tabs[branch_id].destroy() def show_error(self, msg): - messagebox.showerror('Error', message=msg) - + messagebox.showerror("Error", message=msg) + + def show_success(self, msg): + messagebox.showinfo("Success", message=msg) + def right_click_root(self, event): tab_object = event.widget.nametowidget(event.widget.select()) root_id = tab_object.root_id @@ -218,12 +221,12 @@ def get_root_tabs_order(self): self.root_tabs = reordered_dict self.controller.update_root_tabs_order(root_tabs_order) - def update_clipboard_labels(self, number_of_items, total_size_selected): + def update_clipboard_labels(self, number_of_items, total_size_selected, mode): for branch_id in self.branch_tabs.keys(): if total_size_selected is None: - self.clipboard_label_text = f"Clipboard: {number_of_items} Selected" + self.clipboard_label_text = f"Clipboard: {number_of_items} Selected to {mode.capitalize()}" else: - self.clipboard_label_text = f"Clipboard: {number_of_items} Selected {total_size_selected}" + self.clipboard_label_text = f"Clipboard: {number_of_items} Selected to {mode.capitalize()} {total_size_selected}" self.branch_tabs[branch_id].clipboard_label.config(text=self.clipboard_label_text) \ No newline at end of file