def on_drop ( self, x, y, obj, default_drag_result ): """ Called when a drop occurs on the shell. """ # If we can't create a valid Python identifier for the name of an # object we use this instead: name = 'dragged' if hasattr( obj, 'name' ) \ and isinstance( obj.name, basestring ) and len( obj.name ) > 0: py_name = python_name( obj.name ) # Make sure that the name is actually a valid Python identifier: try: if eval( py_name, { py_name : True } ): name = py_name except: pass self.interp.user_ns[ name ] = obj self.execute_command( name, hidden = False ) self.control.SetFocus() # We always copy into the shell since we don't want the data # removed from the source: return wx.DragCopy
def dropEvent ( self, e ): """ Handle a drop on the widget. """ obj = self._dragged_object( e ) if obj is None: return # If we can't create a valid Python identifier for the name of an # object we use this instead: name = 'dragged' if hasattr( obj, 'name' ) \ and isinstance( obj.name, basestring ) and len( obj.name ) > 0: py_name = python_name( obj.name ) # Make sure that the name is actually a valid Python identifier: try: if eval( py_name, { py_name : True } ): name = py_name except: pass self.interpreter.locals[ name ] = obj self.run( name ) self.setFocus() e.setDropAction( Qt.CopyAction ) e.accept()