From 1ad307a4626cbf4b9f203920373b40e0623bd65c Mon Sep 17 00:00:00 2001 From: Alexander Hosking Date: Wed, 20 Sep 2023 10:05:23 -0400 Subject: [PATCH] Feat: Add tkinter to select a folder to process --- mediacopy/file_copy.py | 14 ++++++++++---- mediacopy/tkinter.py | 37 ------------------------------------- 2 files changed, 10 insertions(+), 41 deletions(-) delete mode 100644 mediacopy/tkinter.py diff --git a/mediacopy/file_copy.py b/mediacopy/file_copy.py index fa7a3a2..6e52344 100644 --- a/mediacopy/file_copy.py +++ b/mediacopy/file_copy.py @@ -7,8 +7,14 @@ import pathlib from PIL import Image, ExifTags import pendulum -INGEST_DIR = pathlib.PureWindowsPath( - r'C:\Users\ahosking\Nextcloud\Camera Uploads\Alex\2022') +from tkinter import filedialog +from tkinter import * +root = Tk() +root.withdraw() +INGEST_DIR = filedialog.askdirectory() + +# INGEST_DIR = pathlib.PureWindowsPath( +# r'C:\Users\ahosking\Nextcloud\Camera Uploads\Alex\2022') PHOTO_LIBRARY = '//192.168.1.4/photos/photo_library/' # TODO: Add dircectory traversal file_list = [] @@ -24,8 +30,8 @@ def compare_and_move(): print(root, d_names, f_names) print(file_list) print(len(file_list)) - process_files(file_list) - remove_empty_directories(INGEST_DIR) + # process_files(file_list) + # remove_empty_directories(INGEST_DIR) def process_files(file_list): diff --git a/mediacopy/tkinter.py b/mediacopy/tkinter.py deleted file mode 100644 index 1391f72..0000000 --- a/mediacopy/tkinter.py +++ /dev/null @@ -1,37 +0,0 @@ -import tkinter as tk -from tkinter import filedialog -# from tkinter import * - -class Application(tk.Frame): - def __init__(self, master=None): - super().__init__(master) - self.master = master - self.pack() - self.create_widgets() - - def create_widgets(self): - self.copy_from = tk.Button(self) - self.copy_from["text"] = "Copy from..." - # self.copy_from["command"] = self.get_dir(self.copy_from) - self.copy_from.pack(side="top") - - self.copy_to = tk.Button(self) - self.copy_to["text"] = "Copy to..." - # self.copy_to.bind('', self.get_dir(self.copy_to)) - self.copy_to.pack(side="top") - - - self.quit = tk.Button(self, text="QUIT", fg="red", - command=self.master.destroy) - self.quit.pack(side="bottom") - - def get_dir(self, the_widget): - folder_selected = filedialog.askdirectory() - if len(folder_selected) > 6: - the_widget.config(text=folder_selected) - - -root = tk.Tk() -app = Application(master=root) -app.copy_from.configure(command=app.get_dir(app.copy_from)) -app.mainloop() \ No newline at end of file