-
Notifications
You must be signed in to change notification settings - Fork 0
/
mouseDagClass.py
57 lines (47 loc) · 1.46 KB
/
mouseDagClass.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@author:MCC
@file: mouseDagClass
@time: 2018/11/21 16:32
"""
import sys
import os
import subprocess
sys.path.append(r'C:\cgteamwork\bin\lib\pyside')
from PySide import QtGui as QtWidgets
from PySide import QtCore
from PySide import QtGui
def _getFilePath(urls):
if '///' in urls.toString():
filePath = urls.toString().split('///')[-1]
return filePath
elif '///' not in urls.toString():
filePath = urls.toString()[1:]
return filePath
class My_ListWidget(QtGui.QListWidget):
def __init__(self,parent = None):
super(My_ListWidget,self).__init__(parent)
self.setAcceptDrops(True)
def dragEnterEvent(self, event):
self.information=[]
data = event.mimeData()
urls = data.urls()
if (urls and urls[0].scheme() == 'file'):
event.acceptProposedAction()
def dragMoveEvent(self,event):
data = event.mimeData()
urls = data.urls()
if (urls and urls[0].scheme() == 'file'):
event.acceptProposedAction()
def dropEvent(self, event):
data = event.mimeData()
urls = data.urls()
if (urls and urls[0].scheme() == 'file'):
urls[0].setScheme("")
for uu in urls:
uu=_getFilePath(uu)
self.information.append(uu)
for ii in self.information:
items = QtGui.QListWidgetItem(ii)
self.addItem(items)