MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / add_toolitem

Method add_toolitem

lib/matplotlib/backends/backend_qt.py:1097–1117  ·  view source on GitHub ↗
(
            self, name, group, position, image_file, description, toggle)

Source from the content-addressed store, hash-verified

1095 self._groups = {}
1096
1097 def add_toolitem(
1098 self, name, group, position, image_file, description, toggle):
1099
1100 button = QtWidgets.QToolButton(self)
1101 if image_file:
1102 button.setIcon(NavigationToolbar2QT._icon(self, image_file))
1103 button.setText(name)
1104 if description:
1105 button.setToolTip(description)
1106
1107 def handler():
1108 self.trigger_tool(name)
1109 if toggle:
1110 button.setCheckable(True)
1111 button.toggled.connect(handler)
1112 else:
1113 button.clicked.connect(handler)
1114
1115 self._toolitems.setdefault(name, [])
1116 self._add_to_group(group, name, button, position)
1117 self._toolitems[name].append((button, handler))
1118
1119 def _add_to_group(self, group, name, button, position):
1120 gr = self._groups.get(group, [])

Callers

nothing calls this directly

Calls 3

_add_to_groupMethod · 0.95
_iconMethod · 0.45
connectMethod · 0.45

Tested by

no test coverage detected