From 3e59e6f4fae3611cb533444968724517a4c42fff Mon Sep 17 00:00:00 2001 From: piotrj Date: Mon, 15 Apr 2024 17:08:04 +0200 Subject: [PATCH] drag & drop event binding (main window, new record window) pyinstaller, nuitka update release & distros rename --- .github/workflows/run.yml | 11 +++++------ requirements.txt | 5 +++-- src/librer.py | 36 ++++++++++++++++++++++++++++++++++-- 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index 9ac5d13..8f1be8e 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -258,13 +258,12 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ steps.version.outputs.version }} - name: librer Release ${{ steps.version.outputs.version }} + name: Librer ${{ steps.version.outputs.version }} draft: false prerelease: false files: | - librer.${{ steps.version.outputs.version }}.portable.linux.zip - librer.${{ steps.version.outputs.version }}.portable.linux.nuitka.zip - librer.${{ steps.version.outputs.version }}.portable.windows.zip - librer.${{ steps.version.outputs.version }}.portable.windows.nuitka.zip - + librer.${{ steps.version.outputs.version }}.linux.portable.zip + librer.${{ steps.version.outputs.version }}.linux.nuitka.portable.zip + librer.${{ steps.version.outputs.version }}.windows.portable.zip + librer.${{ steps.version.outputs.version }}.windows.nuitka.portable.zip diff --git a/requirements.txt b/requirements.txt index 47e5bc2..5982029 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,9 @@ -pyinstaller==6.5.0 +pyinstaller==6.6.0 send2trash==1.8.2 zstandard==0.22.0 psutil==5.9.8 pympler==1.0.1 ciso8601==2.3.1 pywin32==306; sys.platform == 'win32' -nuitka==2.1.2 +nuitka==2.1.5 +tkinterdnd2==0.3.0 diff --git a/src/librer.py b/src/librer.py index aaa623e..e5dc950 100755 --- a/src/librer.py +++ b/src/librer.py @@ -27,7 +27,7 @@ #################################################################################### from os import sep,system,getcwd,name as os_name,cpu_count -from os.path import abspath,normpath,dirname,join as path_join,isfile as path_isfile +from os.path import abspath,normpath,dirname,join as path_join,isfile as path_isfile,exists as path_exists,isdir from gc import disable as gc_disable, enable as gc_enable,collect as gc_collect,set_threshold as gc_set_threshold, get_threshold as gc_get_threshold from pathlib import Path @@ -37,6 +37,9 @@ from tkinter import Tk,Toplevel,PhotoImage,Menu,Label,LabelFrame,Frame,StringVar,BooleanVar,IntVar from tkinter.ttk import Treeview,Checkbutton,Radiobutton,Scrollbar,Button,Menubutton,Entry,Scale,Style from tkinter.filedialog import askdirectory,asksaveasfilename,askopenfilename,askopenfilenames + +from tkinterdnd2 import DND_FILES, TkinterDnD + from threading import Thread from traceback import format_stack import sys @@ -348,7 +351,11 @@ def __init__(self,cwd): self.main_locked_by_child=None #################################################################### - self_main = self.main = Tk() + #self_main = self.main = Tk() + self_main = self.main = TkinterDnD.Tk() + + self_main.drop_target_register(DND_FILES) + self_main.dnd_bind('<>', lambda e: self.main_drop(e.data) ) self.main_config = self.main.config @@ -929,6 +936,28 @@ def help_cascade_post(): self_main.mainloop() + def main_drop(self, data): + dialog = self.get_scan_dialog() + self.path_to_scan_entry_var.set(data) + self.scan_label_entry_var.set("dropped_path") + + self.main.after_idle(lambda : self.scan_dialog_show()) + + def scan_dialog_drop(self, data): + if paths := self.main.splitlist(data): + path = paths[0] + p_path = normpath(abspath(path)) + + self.scan_label_entry_var.set("dropped_path") + + if path_exists(p_path): + if isdir(p_path): + self.path_to_scan_entry_var.set(p_path) + else: + self.path_to_scan_entry_var.set(dirname(p_path)) + else: + self.get_info_dialog_on_scan().show('Path does not exist',str(p_path)) + def tree_focus_out(self): tree = self.tree item=tree.focus() @@ -1128,6 +1157,9 @@ def get_scan_dialog(self): self.scan_dialog=dialog=GenericDialog(self.main,(self.ico_record_new,self.ico_record_new),self.bg_color,'---',pre_show=self.pre_show,post_close=self.post_close,min_width=800,min_height=550) + dialog.area_main.drop_target_register(DND_FILES) + dialog.area_main.dnd_bind('<>', lambda e: self.scan_dialog_drop(e.data) ) + self_ico = self.ico #self.log_skipped_var=BooleanVar()