appJar icon indicating copy to clipboard operation
appJar copied to clipboard

Files drag & drop

Open GVicent opened this issue 8 years ago • 13 comments

Hi jarvisteach,

I recently discover your api. It is so well made and simple to code with, I'm using it without moderation.

For my project, I wanted to "drag & drop" files into my application window (to add them in my database). From your doc, I didn't figure out how to manage this, so I am suggesting it as enhancement.

Cordialement. Regards

GVicent avatar Feb 24 '17 20:02 GVicent

Interesting request...

I've implemented a simple drag-and-drop functionality within a single appJar instance:

  • app.addDragFunction(wing, [drag, drop])

This allows you to register a widget to start a drag event and another widget to receive a drop event.

But, this won't work from other applications - as there's no way to register the drag side of the event - appJar won't know what's being dragged, only that something is being dropped...

A quick Google reveals tkDND - a library to implement this.

It looks like it could work, but will need a bunch of research/work - I'll have a look into it after the next release.

On a side note, I also found this, which may provide better drag-and-drop functionality than I've already implemented. Will look into this at the same time...

jarvisteach avatar Feb 24 '17 23:02 jarvisteach

Here's a sample implementation: http://stackoverflow.com/questions/14267900/python-drag-and-drop-explorer-files-to-tkinter-entry-widget/

jarvisteach avatar Feb 24 '17 23:02 jarvisteach

Just had a play with this - works seamlessly on Mac (from Finder to an Entry widget), will try it on the Pi/Windows later

jarvisteach avatar Feb 25 '17 10:02 jarvisteach

This may be a newer version of tkdnd: http://tkinterdnd.sourceforge.net/TkinterDnD.html

jarvisteach avatar Apr 15 '17 13:04 jarvisteach

HI @GVicent - was wondering if you could have a play with this. The new release (0.06) support D'nD between apps on Windows & OSX, and the next_release branch now also has support for RaspberryPi.

Have a look at: http://appjar.info/pythonDnD/ for some help...

jarvisteach avatar Apr 18 '17 13:04 jarvisteach

Hopefully, now can distinguish between arm/x86 linux and load the right library. Need x86 platform to test on, and still will be some issues between 32 & 64 bit...

jarvisteach avatar May 26 '17 20:05 jarvisteach

Since the documentation says "....- at the moment, this has been seen to work on Mac OSX 10.11, Raspberry Pi, and Windows 7 - let us know of success on other distributions!": I can confirm dragging a file name from another application into an Entry field also works in Windows 10 64bit Pro Version 1703 and 1709.

WilfriedBl avatar Nov 20 '17 12:11 WilfriedBl

Excellent news! Thank you :)

On 20 Nov 2017, at 12:53, WilfriedBl [email protected] wrote:

Since the documentation says "....- at the moment, this has been seen to work on Mac OSX 10.11, Raspberry Pi, and Windows 7 - let us know of success on other distributions!": I can confirm dragging a file name from another application into an Entry field also works in Windows 10 64bit Pro Version 1703 and 1709.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub, or mute the thread.

jarvisteach avatar Nov 20 '17 16:11 jarvisteach

I just realized, it does not work on Windows 10 32bit: Traceback (most recent call last): File "d:\anzgeotags\anzgeotags.py", line 1396, in <module> build_GUI_panel() File "d:\anzgeotags\anzgeotags.py", line 1320, in build_GUI_panel if tr == '1': gui.setEntryDropTarget("Image" + tr, dropped_name_image1, replace=True) File "<string>", line 1, in setEntryDropTarget File "C:\Users\WBL\AppData\Local\Programs\Python\Python36-32\lib\site-packages\appJar\appjar.py", line 2606, in configureWidgets self.configureWidget(kind, names, option, value) File "C:\Users\WBL\AppData\Local\Programs\Python\Python36-32\lib\site-packages\appJar\appjar.py", line 2807, in configureWidget self.__registerExternalDropTarget(name, item, value[0], value[1]) File "C:\Users\WBL\AppData\Local\Programs\Python\Python36-32\lib\site-packages\appJar\appjar.py", line 1133, in __registerExternalDropTarget raise Exception("External Drag'n Drop not available on this platform") Exception: External Drag'n Drop not available on this platform

WilfriedBl avatar Dec 13 '17 17:12 WilfriedBl

Thanks for the info @WilfriedBl - I will probably need to find a 32 bit compiled version of the library for dnd - I'll drop you a message to test it when I get one sorted.

jarvisteach avatar Dec 15 '17 00:12 jarvisteach

Not sure, how common 32bit Windows still is. It's just important to know, there is a restriction. For myself (just using an old PC for testing), I found the workaround in this way: import platform if platform.architecture()[0] == '64bit': gui.setEntryDropTarget("Image" + tr, dropped_name_image, replace=True) gui.setEntryTooltip("Image" + tr, "Drag any image file here")

WilfriedBl avatar Dec 15 '17 07:12 WilfriedBl

I am having issues compiling with the DnD. I am getting a similar error at @WilfriedBl I am running Windows 10 64 bit and Python 3.7.2 (64-bit) Traceback (most recent call last): File "SubmittalBuilder.py", line 330, in <module> File "SubmittalBuilder.py", line 289, in onLoad File "<string>", line 1, in setListBoxDropTarget File "site-packages\appJar\appjar.py", line 2879, in configureWidgets File "site-packages\appJar\appjar.py", line 3057, in configureWidget File "site-packages\appJar\appjar.py", line 1060, in _registerExternalDropTarget Exception: External Drag'n Drop not available on this platform

Any suggestions are welcome!

thothloki avatar Jun 20 '19 15:06 thothloki

@thothloki managed to solve? i am having the same error.

ale-cardosof avatar Mar 15 '22 22:03 ale-cardosof