(self)
This is called whenever the item is being moved and needs to
        recalculate its offset.
This is called whenever the item is being moved and needs to
        recalculate its offset.
This is called whenever the item is being moved and needs to recalculate its offset .
def recalculate_offset(self):
        """This is called whenever the item is being moved and needs to
        recalculate its offset."""
        view = self.__get_view()
        # Get the view box and position of legend relative to the view,
        # not the scene
        pos = view.mapFromScene(self.pos())
        view_box = self.__usable_viewbox()

        self.__corner_str = self.__get_closest_corner()
        viewbox_corner = getattr(view_box, self.__corner_str)()

        self.__offset = viewbox_corner - pos
def recalculate_offset ( self ) : view = self . __get_view ( ) # Get the view box and position of legend relative to the view, # not the scene pos = view . mapFromScene ( self . pos ( ) ) view_box = self . __usable_viewbox ( ) self . __corner_str = self . __get_closest_corner ( ) viewbox_corner = getattr ( view_box , self . __corner_str ) ( ) self . __offset = viewbox_corner - pos