code: def __init__(self, view):
      QtWidgets.QMenu.__init__(self)
  
      self.view = weakref.ref(
          view
      )  ## keep weakref to view to avoid circular reference (don't know why, but this prevents the ViewBox from being collected)
      self.valid = False  ## tells us whether the ui needs to be updated
      self.viewMap = (
          weakref.WeakValueDictionary()
      )  ## weakrefs to all views listed in the link combos
  
      self.setTitle(translate("ViewBox", "ViewBox options"))
      self.viewAll = QtGui.QAction(
          translate("ViewBox", "View All"), self
      )
      self.viewAll.triggered.connect(self.autoRange)
      self.addAction(self.viewAll)
  
      self.ctrl = []
      self.widgetGroups = []
      self.dv = QtGui.QDoubleValidator(self)
      for axis in "XY":
          m = self.addMenu(f"{axis} {translate('ViewBox', 'axis')}")
          w = QtWidgets.QWidget()
          ui = ui_template.Ui_Form()
          ui.setupUi(w)
          a = QtWidgets.QWidgetAction(self)
          a.setDefaultWidget(w)
          m.addAction(a)
          self.ctrl.append(ui)
          wg = WidgetGroup(w)
          self.widgetGroups.append(wg)
  
          connects = [
              (ui.mouseCheck.toggled, "MouseToggled"),
              (ui.manualRadio.clicked, "ManualClicked"),
              (ui.minText.editingFinished, "RangeTextChanged"),
              (ui.maxText.editingFinished, "RangeTextChanged"),
              (ui.autoRadio.clicked, "AutoClicked"),
              (ui.autoPercentSpin.valueChanged, "AutoSpinChanged"),
              (ui.linkCombo.currentIndexChanged, "LinkComboChanged"),
              (ui.autoPanCheck.toggled, "AutoPanToggled"),
              (ui.visibleOnlyCheck.toggled, "VisibleOnlyToggled"),
          ]
  
          for sig, fn in connects:
              sig.connect(getattr(self, axis.lower() + fn))
  
      self.ctrl[0].invertCheck.toggled.connect(self.xInvertToggled)
      self.ctrl[1].invertCheck.toggled.connect(self.yInvertToggled)
  
      leftMenu = self.addMenu(translate("ViewBox", "Mouse Mode"))
  
      group = QtGui.QActionGroup(self)
      group.triggered.connect(self.setMouseMode)
      pan = QtGui.QAction(translate("ViewBox", "3 button"), group)
      zoom = QtGui.QAction(translate("ViewBox", "1 button"), group)
      pan.setCheckable(True)
      zoom.setCheckable(True)
  
      leftMenu.addActions(group.actions())
  
      self.mouseModes = [pan, zoom]
  
      self.view().sigStateChanged.connect(self.viewStateChanged)
  
      self.updateState()
  
imports: from ...Qt import QtCore, QtGui, QtWidgets
  from ...WidgetGroup import WidgetGroup
  from .None import axisCtrlTemplate_generic
  import weakref
  from .ViewBox import ViewBox
label_desc: Use image node_id 1 to create a new ViewBoxMenu object from inherited base classes: QtWidgets with example: obj = ViewBoxMenu(view)