简体   繁体   中英

Python Desktop Integration - Drag and drop

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?

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.

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
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM