Discussion:
[python-win32] Windows drag and drop functionality
Nisarg Kothari
2005-05-25 03:07:22 UTC
Permalink
I need a way to drag and drop file[names] from windows into some Python
based gui. The only thing I found remotely close to what I'm looking for
is Tkdnd.py, but that only works within the program. I need support for
dragging from the windows desktop or explorer window. As I have not yet
begun making the GUI, I'm open to any kind of solution. If it is
necessary I can use a compiled snippet of some other language (Java?) to
call my python, either in script or executable form (via py2exe). This
is a windows only project so cross-platform support is not necessary.
Any suggestions?
Tim Golden
2005-05-25 15:22:42 UTC
Permalink
[Nisarg Kothari]

| I need a way to drag and drop file[names] from windows into
| some Python based gui. The only thing I found remotely close
| to what I'm looking for is Tkdnd.py, but that only works within
| the program. I need support for dragging from the windows desktop
| or explorer window.

You can certainly do this from wxPython:

http://wiki.wxpython.org/index.cgi/DragAndDrop

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
Roger Upole
2005-05-25 23:03:24 UTC
Permalink
If you're using native windows, you can catch the WM_DROPFILES
window message and use win32api.DragQueryFile to get the names of dropped
files.

Roger
Post by Nisarg Kothari
I need a way to drag and drop file[names] from windows into some Python
based gui. The only thing I found remotely close to what I'm looking for
is Tkdnd.py, but that only works within the program. I need support for
dragging from the windows desktop or explorer window. As I have not yet
begun making the GUI, I'm open to any kind of solution. If it is
necessary I can use a compiled snippet of some other language (Java?) to
call my python, either in script or executable form (via py2exe). This
is a windows only project so cross-platform support is not necessary.
Any suggestions?
Mark Hammond
2005-05-26 00:54:00 UTC
Permalink
Post by Roger Upole
If you're using native windows, you can catch the WM_DROPFILES
window message and use win32api.DragQueryFile to get the
names of dropped
files.
It may also be necessary to call DragAcceptFiles. This is missing from
win32gui (but has been addded), but does exist in win32ui. You may need to
do something like:

win32ui.CreateWindowFromHandle(hwnd).DragAcceptFiles(True)

In builds 205 and later you will be able to say:

win32gui.DragAcceptFiles(hwnd, True)

Mark

Loading...