Python tkinter文件拖拽

1,windnd

对 windows 桌面图标拖拽加载路径

安装:pip install windnd

from tkinter import *
import windnd

for idx,i in enumerate(ls):
    print(idx,i)

tk = Tk()
windnd.hook_dropfiles(tk,func = my_func
tk.mainloop() 

ps:遇到问题,在使用滚动条的时候会发生错误,没有继续调试下去,换了tkdnd

2,tkdnd2.8 & tkinterDnD2

对 windows 桌面图标拖拽加载路径

tkdnd2.8:https://sourceforge.net/projects/tkdnd/

TkinterDnD2:http://sourceforge.net/projects/tkinterdnd/files/

将tkdnd2.8文件夹复制到c:\Python36-32\tcl\ 

将TkinterDnD2文件夹复制到C:\Python36-32\Lib\ (下载的是TkinterDnD2-0.2文件夹要复制的是里面的那个)

简单例子: 直接使用TkinterDnD2-0.2文件夹下的demo
posted @ 2022-10-09 10:26  interesting5319  阅读(1126)  评论(0)    收藏  举报