code: def __init__(self, item, **opts):
      defOpts = {
          "name": None,
          "z": None,
          "movable": True,
          "scalable": False,
          "rotatable": True,
          "visible": True,
          "parent": None,
      }  #'pos': [0,0], 'scale': [1,1], 'angle':0,
      defOpts.update(opts)
      self.opts = defOpts
      self.selectedAlone = (
          False  ## whether this item is the only one selected
      )
  
      QtCore.QObject.__init__(self)
      self.canvas = None
      self._graphicsItem = item
  
      parent = self.opts["parent"]
      if parent is not None:
          self._graphicsItem.setParentItem(parent.graphicsItem())
          self._parentItem = parent
      else:
          self._parentItem = None
  
      z = self.opts["z"]
      if z is not None:
          item.setZValue(z)
  
      self.ctrl = QtWidgets.QWidget()
      self.layout = QtWidgets.QGridLayout()
      self.layout.setSpacing(0)
      self.layout.setContentsMargins(0, 0, 0, 0)
      self.ctrl.setLayout(self.layout)
  
      self.alphaLabel = QtWidgets.QLabel(
          translate("CanvasItem", "Alpha")
      )
      self.alphaSlider = QtWidgets.QSlider()
      self.alphaSlider.setMaximum(1023)
      self.alphaSlider.setOrientation(QtCore.Qt.Orientation.Horizontal)
      self.alphaSlider.setValue(1023)
      self.layout.addWidget(self.alphaLabel, 0, 0)
      self.layout.addWidget(self.alphaSlider, 0, 1)
      self.resetTransformBtn = QtWidgets.QPushButton("Reset Transform")
      self.copyBtn = QtWidgets.QPushButton("Copy")
      self.pasteBtn = QtWidgets.QPushButton("Paste")
  
      self.transformWidget = QtWidgets.QWidget()
      self.transformGui = ui_template.Ui_Form()
      self.transformGui.setupUi(self.transformWidget)
      self.layout.addWidget(self.transformWidget, 3, 0, 1, 2)
      self.transformGui.mirrorImageBtn.clicked.connect(self.mirrorY)
      self.transformGui.reflectImageBtn.clicked.connect(self.mirrorXY)
  
      self.layout.addWidget(self.resetTransformBtn, 1, 0, 1, 2)
      self.layout.addWidget(self.copyBtn, 2, 0, 1, 1)
      self.layout.addWidget(self.pasteBtn, 2, 1, 1, 1)
      self.alphaSlider.valueChanged.connect(self.alphaChanged)
      self.alphaSlider.sliderPressed.connect(self.alphaPressed)
      self.alphaSlider.sliderReleased.connect(self.alphaReleased)
      self.resetTransformBtn.clicked.connect(self.resetTransformClicked)
      self.copyBtn.clicked.connect(self.copyClicked)
      self.pasteBtn.clicked.connect(self.pasteClicked)
  
      self.setMovable(
          self.opts["movable"]
      )  ## update gui to reflect this option
  
      if "transform" in self.opts:
          self.baseTransform = self.opts["transform"]
      else:
          self.baseTransform = SRTTransform()
          if "pos" in self.opts and self.opts["pos"] is not None:
              self.baseTransform.translate(self.opts["pos"])
          if "angle" in self.opts and self.opts["angle"] is not None:
              self.baseTransform.rotate(self.opts["angle"])
          if "scale" in self.opts and self.opts["scale"] is not None:
              self.baseTransform.scale(self.opts["scale"])
  
      ## create selection box (only visible when selected)
      tr = self.baseTransform.saveState()
      if "scalable" not in opts and tr["scale"] == (1, 1):
          self.opts["scalable"] = True
  
      ## every CanvasItem implements its own individual selection box
      ## so that subclasses are free to make their own.
      self.selectBox = SelectBox(
          scalable=self.opts["scalable"],
          rotatable=self.opts["rotatable"],
      )
      self.selectBox.hide()
      self.selectBox.setZValue(1e6)
      self.selectBox.sigRegionChanged.connect(
          self.selectBoxChanged
      )  ## calls selectBoxMoved
      self.selectBox.sigRegionChangeFinished.connect(
          self.selectBoxChangeFinished
      )
  
      ## set up the transformations that will be applied to the item
      ## (It is not safe to use item.setTransform, since the item might count on that not changing)
      self.itemRotation = QtWidgets.QGraphicsRotation()
      self.itemScale = QtWidgets.QGraphicsScale()
      self._graphicsItem.setTransformations(
          [self.itemRotation, self.itemScale]
      )
  
      self.tempTransform = (
          SRTTransform()
      )  ## holds the additional transform that happens during a move - gets added to the userTransform when move is done.
      self.userTransform = (
          SRTTransform()
      )  ## stores the total transform of the object
      self.resetUserTransform()
  
imports: import importlib
  from ..None import ItemGroup, SRTTransform, debug
  from ..None import functions
  from ..graphicsItems.ROI import ROI
  from ..Qt import QT_LIB, QtCore, QtWidgets
  from .None import TransformGuiTemplate_generic
label_desc: Use image node_id 1 to create a new CanvasItem object from inherited base classes: QtCore with example: obj = CanvasItem(item)