Esempio n. 1
0
 def dropEvent(self, event):
     """Reimplement Qt method
     Unpack dropped data and handle it"""
     source = event.mimeData()
     shellwidget = self.tabwidget.currentWidget()
     if source.hasText():
         qstr = source.text()
         if is_python_script(to_text_string(qstr)):
             self.start(qstr)
         elif shellwidget:
             shellwidget.shell.insert_text(qstr)
     elif source.hasUrls():
         pathlist = mimedata2url(source)
         if all(
             [is_python_script(to_text_string(qstr)) for qstr in pathlist]):
             for fname in pathlist:
                 self.start(fname)
         elif shellwidget:
             shellwidget.shell.drop_pathlist(pathlist)
     event.acceptProposedAction()
Esempio n. 2
0
 def dropEvent(self, event):
     """Reimplement Qt method
     Unpack dropped data and handle it"""
     source = event.mimeData()
     shellwidget = self.tabwidget.currentWidget()
     if source.hasText():
         qstr = source.text()
         if is_python_script(to_text_string(qstr)):
             self.start(qstr)
         elif shellwidget:
             shellwidget.shell.insert_text(qstr)
     elif source.hasUrls():
         pathlist = mimedata2url(source)
         if all([is_python_script(to_text_string(qstr)) 
                 for qstr in pathlist]):
             for fname in pathlist:
                 self.start(fname)
         elif shellwidget:
             shellwidget.shell.drop_pathlist(pathlist)
     event.acceptProposedAction()
Esempio n. 3
0
 def dragEnterEvent(self, event):
     """Reimplement Qt method
     Inform Qt about the types of data that the widget accepts"""
     source = event.mimeData()
     if source.hasUrls():
         if mimedata2url(source):
             pathlist = mimedata2url(source)
             shellwidget = self.tabwidget.currentWidget()
             if all([is_python_script(to_text_string(qstr))
                     for qstr in pathlist]):
                 event.acceptProposedAction()
             elif shellwidget is None or not shellwidget.is_running():
                 event.ignore()
             else:
                 event.acceptProposedAction()
         else:
             event.ignore()
     elif source.hasText():
         event.acceptProposedAction()            
Esempio n. 4
0
 def dragEnterEvent(self, event):
     """Reimplement Qt method
     Inform Qt about the types of data that the widget accepts"""
     source = event.mimeData()
     if source.hasUrls():
         if mimedata2url(source):
             pathlist = mimedata2url(source)
             shellwidget = self.tabwidget.currentWidget()
             if all([is_python_script(to_text_string(qstr))
                     for qstr in pathlist]):
                 event.acceptProposedAction()
             elif shellwidget is None or not shellwidget.is_running():
                 event.ignore()
             else:
                 event.acceptProposedAction()
         else:
             event.ignore()
     elif source.hasText():
         event.acceptProposedAction()