|
27 | 27 | ####################################################################################
|
28 | 28 |
|
29 | 29 | from os import sep,system,getcwd,name as os_name,cpu_count
|
30 |
| -from os.path import abspath,normpath,dirname,join as path_join,isfile as path_isfile |
| 30 | +from os.path import abspath,normpath,dirname,join as path_join,isfile as path_isfile,exists as path_exists,isdir |
31 | 31 | 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
|
32 | 32 |
|
33 | 33 | from pathlib import Path
|
|
37 | 37 | from tkinter import Tk,Toplevel,PhotoImage,Menu,Label,LabelFrame,Frame,StringVar,BooleanVar,IntVar
|
38 | 38 | from tkinter.ttk import Treeview,Checkbutton,Radiobutton,Scrollbar,Button,Menubutton,Entry,Scale,Style
|
39 | 39 | from tkinter.filedialog import askdirectory,asksaveasfilename,askopenfilename,askopenfilenames
|
| 40 | + |
| 41 | +from tkinterdnd2 import DND_FILES, TkinterDnD |
| 42 | + |
40 | 43 | from threading import Thread
|
41 | 44 | from traceback import format_stack
|
42 | 45 | import sys
|
@@ -348,7 +351,11 @@ def __init__(self,cwd):
|
348 | 351 |
|
349 | 352 | self.main_locked_by_child=None
|
350 | 353 | ####################################################################
|
351 |
| - self_main = self.main = Tk() |
| 354 | + #self_main = self.main = Tk() |
| 355 | + self_main = self.main = TkinterDnD.Tk() |
| 356 | + |
| 357 | + self_main.drop_target_register(DND_FILES) |
| 358 | + self_main.dnd_bind('<<Drop>>', lambda e: self.main_drop(e.data) ) |
352 | 359 |
|
353 | 360 | self.main_config = self.main.config
|
354 | 361 |
|
@@ -929,6 +936,28 @@ def help_cascade_post():
|
929 | 936 |
|
930 | 937 | self_main.mainloop()
|
931 | 938 |
|
| 939 | + def main_drop(self, data): |
| 940 | + dialog = self.get_scan_dialog() |
| 941 | + self.path_to_scan_entry_var.set(data) |
| 942 | + self.scan_label_entry_var.set("dropped_path") |
| 943 | + |
| 944 | + self.main.after_idle(lambda : self.scan_dialog_show()) |
| 945 | + |
| 946 | + def scan_dialog_drop(self, data): |
| 947 | + if paths := self.main.splitlist(data): |
| 948 | + path = paths[0] |
| 949 | + p_path = normpath(abspath(path)) |
| 950 | + |
| 951 | + self.scan_label_entry_var.set("dropped_path") |
| 952 | + |
| 953 | + if path_exists(p_path): |
| 954 | + if isdir(p_path): |
| 955 | + self.path_to_scan_entry_var.set(p_path) |
| 956 | + else: |
| 957 | + self.path_to_scan_entry_var.set(dirname(p_path)) |
| 958 | + else: |
| 959 | + self.get_info_dialog_on_scan().show('Path does not exist',str(p_path)) |
| 960 | + |
932 | 961 | def tree_focus_out(self):
|
933 | 962 | tree = self.tree
|
934 | 963 | item=tree.focus()
|
@@ -1128,6 +1157,9 @@ def get_scan_dialog(self):
|
1128 | 1157 |
|
1129 | 1158 | 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)
|
1130 | 1159 |
|
| 1160 | + dialog.area_main.drop_target_register(DND_FILES) |
| 1161 | + dialog.area_main.dnd_bind('<<Drop>>', lambda e: self.scan_dialog_drop(e.data) ) |
| 1162 | + |
1131 | 1163 | self_ico = self.ico
|
1132 | 1164 |
|
1133 | 1165 | #self.log_skipped_var=BooleanVar()
|
|
0 commit comments