wxpython 拖拽
来源:互联网 发布:算法1mints.txt 编辑:程序博客网 时间:2024/06/05 10:11
从本地拖拽到窗口比较简单没有太大问题,
但是从窗口中拖拽带 资源管理器中搞了半天
由于文件全部在远程,从窗口拖拽到桌面中,需要使用com 比较麻烦,先简单实现吧
使用windowfrompoint获取窗口句柄来获取拖拽结束路径
from win32com.shell import shell, shellcondef BeginDragFile(self):data = wx.FileDataObject()dropSource = wx.DropSource(self)dropSource.SetData(data)result= dropSource.DoDragDrop(0)if not result:returnh=win32gui.WindowFromPoint(win32api.GetCursorPos())#结束是鼠标在文件资源管理器上if win32gui.GetWindowText(h)=='FolderView':f=win32gui.GetForegroundWindow()#获取文件资源管理器title就是路径path=win32gui.GetWindowText(f)#是否为桌面if path=='Program Manager':path=shell.SHGetPathFromIDList(shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_DESKTOP))if os.path.isdir(path):return path
最后获取的就是拖拽结束的路径,直接使用该路径执行下载操作
2012 12 24 更新 添加win7支持
def RawDragPath(self):data = wx.FileDataObject()dropSource = wx.DropSource(self)dropSource.SetData(data)result= dropSource.DoDragDrop(0)h=win32gui.WindowFromPoint(win32api.GetCursorPos())f=win32gui.GetForegroundWindow()if not result:returnpath=''#结束是鼠标在文件资源管理器上if f==windll.user32.GetAncestor(h,2):path=shell.SHGetPathFromIDList(shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_DESKTOP))else:s = win32com.client.Dispatch("Shell.Application")for w in s.Windows():if int(w.Hwnd) == f:path = w.LocationURL.split('///')[1]path=urllib2.unquote(path)breakif os.path.isdir(path):return path
- wxpython 拖拽
- wxPython
- wxPython
- wxPython
- wxpython
- wxPython
- wxpython
- wxPython之hello wxPython
- wxPython:关闭wxPython程序
- 【wxPython】wxPython简介
- wxPython.wx
- wxPython menu
- wxpython trick
- wxPython简介
- wxPython 入门
- Hello,wxPython
- 学习wxpython
- wxPython 入门
- Android 源码分析 -- (一) Android启动过程
- android之init进程-uevent
- 如何找出重名的全局变量
- 如何让虚拟机对外提供服务
- 往android的内核添加驱动及 ueventd.rc 修改
- wxpython 拖拽
- 从头开始学C
- learn iphone and ipad cocos2d Game Development读书笔记
- UDP协议详解与QUdpSocket编程
- POJ 1850 Code
- eval解析JSON中的注意点
- 通过JS自动隐藏手机浏览器的地址栏
- siverlight使用渐变效果实现遮罩效果
- Union 共用体