Schilcote
Schilcote

Reputation: 2404

Accessing the Windows mechanism that allows drag-and-drop between programs in Python 3

I can click-and-drag a link in Firefox down to my taskbar and place the cursor over the icon for Word, which will come to the foreground and allow me to drop the link into a Word document.

I need a Python program to be able to accept links in exactly the same way. What's the name of the system that allows this to happen (OLE?), and how can I access it from Python? Is there a platform-independent means to do so (that is, a similar system that will work on MacOS)?

Upvotes: 4

Views: 324

Answers (1)

Sam Mussmann
Sam Mussmann

Reputation: 5993

Based on this article from the QT site, it seems like OLE is the system that does drag and drop on Windows.

It looks like QT would provide the platform-independence that you want, since it implements appropriate protocols for Mac, Linux, and Windows. You can use it from Python with PyQt or PySide (the official Python bindings for QT). The differences between these two bindings are minimal, although the licenses are quite different.

I did do some searching around for Tkinter drag and drop stuff, and didn't find much (although I did find this question several times...). There is an extension for Tk called TkDND, and it is possible to write Python extensions for it. However, development on this extension does not seem active, so I don't know how well it would work today in practice.

TL;DR Tkinter might work, but QT is a sure bet

Upvotes: 1

Related Questions