Пример #1
0
	def eventFilter(self,obj,event):
		if (event.type()==QEvent.DragEnter):
			if event.mimeData().hasUrls():
				event.accept()   # must accept the dragEnterEvent or else the dropEvent can't occur !!!
			else:
				event.ignore()
		if (event.type() == QEvent.Drop):
			if event.mimeData().hasUrls():   # if file or link is dropped
				file_manager.update_history(*[url.toString()[8:] for url in event.mimeData().urls()])
				url = event.mimeData().urls()[0]   # get first url
				filename=url.toString()
				filename=str(filename)
				filename=filename.split('file:///')[1]
				print('filename={}'.format(filename))
				self.plotWavFile(filename)  #This fails on windows symbolic links.  http://stackoverflow.com/questions/15258506/os-path-islink-on-windows-with-python
				event.accept()
			else:
				event.ignore()
		return False # lets the event continue to the edit
 def eventFilter(self, obj, event):
     if (event.type()==QtCore.QEvent.DragEnter):
         if event.mimeData().hasUrls():
             event.accept()   # must accept the dragEnterEvent or else the dropEvent can't occur !!!
         else:
             event.ignore()
     if (event.type() == QtCore.QEvent.Drop):
         if event.mimeData().hasUrls():   # if file or link is dropped
             url = event.mimeData().urls()[0]   # get first url
             filename=url.toString()
             filename=filename.split('file:///')[1]
             if filename.endswith('.txt'):
                 self.statusBar().showMessage('Loading points from %s' % (filename))
                 self.read_file(filename)
                 fm.update_history(filename)
             else:
                 self.statusBar().showMessage('No support for %s files...' % filename[-4])
             event.accept()
         else:
             event.ignore()
     return False # lets the event continue to the edit
Пример #3
0
 def eventFilter(self, obj, event):
     if (event.type()==QtCore.QEvent.DragEnter):
         if event.mimeData().hasUrls():
             event.accept()   # must accept the dragEnterEvent or else the dropEvent can't occur !!!
         else:
             event.ignore()
     if (event.type() == QtCore.QEvent.Drop):
         if event.mimeData().hasUrls():   # if file or link is dropped
             url = event.mimeData().urls()[0]   # get first url
             filename=url.toString()
             filename=filename.split('file:///')[1]
             if filename.endswith('.txt'):
                 dataWindow.statusBar().showMessage('Loading points from %s' % (filename))
                 import_channels(filename)
                 file_manager.update_history(filename)
             else:
                 obj.statusBar().showMessage('%s widget does not support %s files...' % (obj.__name__, filetype))
             event.accept()
         else:
             event.ignore()
     return False # lets the event continue to the edit