class_docstr: Class used to allow GraphicsWidgets to anchor to a specific position on their
  parent. The item will be automatically repositioned if the parent is resized. 
  This is used, for example, to anchor a LegendItem to a corner of its parent 
  PlotItem.
docstr: Anchors the item at its local itemPos to the item's parent at parentPos.
  Both positions are expressed in values relative to the size of the item or parent;
  a value of 0 indicates left or top edge, while 1 indicates right or bottom edge.
  
  Optionally, offset may be specified to introduce an absolute offset. 
  
  Example: anchor a box such that its upper-right corner is fixed 10px left
  and 10px down from its parent's upper-right corner::
  
      box.anchor(itemPos=(1,0), parentPos=(1,0), offset=(-10,10))
docstr_tok: ["Anchors","the","item","at","its","local","itemPos","to","the","item","'s","parent","at","parentPos",".","Both","positions","are","expressed","in","values","relative","to","the","size","of","the","item","or","parent",";","a","value","of","0","indicates","left","or","top","edge",",","while","1","indicates","right","or","bottom","edge",".","Optionally",",","offset","may","be","specified","to","introduce","an","absolute","offset",".","Example",":","anchor","a","box","such","that","its","upper-right","corner","is","fixed","10px","left","and","10px","down","from","its","parent","'s","upper-right","corner",":",":","box.anchor","(","itemPos=","(","1,0",")",",","parentPos=","(","1,0",")",",","offset=","(","-10,10",")",")"]
code: def anchor(self, itemPos, parentPos, offset=(0, 0)):
      """
      Anchors the item at its local itemPos to the item's parent at parentPos.
      Both positions are expressed in values relative to the size of the item or parent;
      a value of 0 indicates left or top edge, while 1 indicates right or bottom edge.
  
      Optionally, offset may be specified to introduce an absolute offset.
  
      Example: anchor a box such that its upper-right corner is fixed 10px left
      and 10px down from its parent's upper-right corner::
  
          box.anchor(itemPos=(1,0), parentPos=(1,0), offset=(-10,10))
      """
      parent = self.parentItem()
      if parent is None:
          raise Exception("Cannot anchor; parent is not set.")
  
      if self.__parent is not parent:
          if self.__parent is not None:
              self.__parent.geometryChanged.disconnect(
                  self.__geometryChanged
              )
  
          self.__parent = parent
          parent.geometryChanged.connect(self.__geometryChanged)
  
      self.__itemAnchor = itemPos
      self.__parentAnchor = parentPos
      self.__offset = offset
      self.__geometryChanged()
  
imports: from ..Point import Point
label_desc: Use image node_id 2 for calling the GraphicsWidgetAnchor obj's underlying member method code with example usage: obj.anchor(itemPos, parentPos, offset) without return types