Python桌面集成 - 拖放

时间:2021-10-22 21:22:31

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?

我有一个pygame窗口,我想知道一个文件被拖放到它上面。我只需要能够获取文件的名称。如何实现这一目标?

2 个解决方案

#1


4  

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.

以及msdn页面的链接。你可能想要pythoncom库。

#2


0  

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.

类似效果的一个选项是使用pygame的剪贴模块,这样你可以复制粘贴到窗口,你的程序只需要查找ctr-V事件。

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

在我正在使用的这个XFCE桌面上如果我选择了一个文件命中ctrl-C,当我输入时会显示文件名

pygame.scrap.init()

types= pygame.scrap.get_types()

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

#1


4  

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.

以及msdn页面的链接。你可能想要pythoncom库。

#2


0  

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.

类似效果的一个选项是使用pygame的剪贴模块,这样你可以复制粘贴到窗口,你的程序只需要查找ctr-V事件。

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

在我正在使用的这个XFCE桌面上如果我选择了一个文件命中ctrl-C,当我输入时会显示文件名

pygame.scrap.init()

types= pygame.scrap.get_types()

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