Python Desktop Integration - Drag and drop

1.5k Views Asked by At

I have a pygame window that I want to know when a file has been dragged and dropped onto it. I only need to be able to fetch the name of the file. How can this be accomplished?

2

There are 2 best solutions below

0
On BEST ANSWER

Here's a forum thread that might be what you're looking for.

And another forum.

And a link to the msdn page. You'll probably want the pythoncom library.

0
On

one option for a similar effect is is to use pygame's scrap module so you can copy-paste into the window, your program would just need to look for ctr-V events.

On this XFCE desktop I'm using If I hit ctrl-C with a file selected, the file name shows up when I type

pygame.scrap.init()

types= pygame.scrap.get_types()

print dict(
    [type,pygame.scrap.get(type)] 
    for type intypes
)