jarvisteach / appJar

Simple Tkinter GUIs in Python
http://appJar.info
Other
613 stars 68 forks source link

Files drag & drop #101

Open GVicent opened 7 years ago

GVicent commented 7 years ago

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

jarvisteach commented 7 years ago

Interesting request...

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

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 commented 7 years ago

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

jarvisteach commented 7 years ago

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 commented 7 years ago

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

jarvisteach commented 7 years ago

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 commented 7 years ago

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...

WilfriedBl commented 6 years ago

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.

jarvisteach commented 6 years ago

Excellent news! Thank you :)

On 20 Nov 2017, at 12:53, WilfriedBl notifications@github.com 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.

WilfriedBl commented 6 years ago

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

jarvisteach commented 6 years ago

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.

WilfriedBl commented 6 years ago

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")

thothloki commented 5 years ago

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!

ale-cardosof commented 2 years ago

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