issue with a file DnD on Windows, from external app to Python app with this library
TrevorMarvinPNNL opened this issue · 2 comments
(Originally posted in python/cpython, closed there and opened here because of using this repo's library.)
Handling of a Drag-n-Drop event with tkinter causes an exception:
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 1920, in __call__
args = self.subst(*args)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 1605, in _substitute
e.serial = getint(nsign)
_tkinter.TclError: expected integer but got "%#"
The basic code used is this (more code is in the app, but this should be the relevant parts of the setup):
def drop(event):
print("DROP EVENT:", event) # test code to see what's delivered
import tkinterDnD
root = tkinterDnD.Tk()
root.register_drop_target("*")
root.bind("<<Drop>>", drop)
The intent is to capture a file dragged from another application. With the 'register' function, this Python program and the OS indicate that the program's window is a valid place to drop a file dragged from a file manager program (specifically using Windows Explorer). After 'dropping', the error shown above is seen.
Environment:
CPython versions tested on: Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0
Operating system and architecture: Windows 10
Thanks for reporting this! I'll definitely look into it when I have acces to some Windows.
Happens on macOS as well.