33 from python_qt_binding.QtCore
import QSize, Qt
34 from python_qt_binding.QtWidgets
import QToolBar, QGroupBox, QHBoxLayout
40 Base class from which dashboards should inherit.
42 :param context: the plugin context
43 :type context: qt_gui.plugin.Plugin
46 super(Dashboard, self).
__init__(context)
50 if not hasattr(self,
'name'):
52 if not hasattr(self,
'max_icon_size'):
58 if context.serial_number() > 1:
69 Called during ``__init__`` Subclasses should do initialization here.
71 NOTE when overriding this method you should provide a ``self.name`` to
72 avoid naming conflicts.
74 :param context: The plugin context
75 :type context: qt_gui.plugin.Plugin
81 Called when the toolbar is closed by Qt.
83 for widget
in self._widgets:
84 if hasattr(widget,
'shutdown_widget'):
85 widget.shutdown_widget()
86 if hasattr(widget,
'close'):
89 self.shutdown_dashboard()
93 Called after shutdown plugin, subclasses should do cleanup here, not in shutdown_plugin
99 Most of the dashboard customization should be done here.
100 If this function is not overriden the dashboard will display nothing.
102 :returns: List of lists containing dashboard widgets, or list of lists
103 containing a string followed by a list of dashboard widgets.
109 Add groups of widgets to _main_widget. Supports group labels.
111 This method can be reimplemented in order to customize appearances.
115 for group
in widgets:
117 if isinstance(group[0], str):
118 grouplabel, v = group
119 box = QGroupBox(grouplabel)
120 box.setContentsMargins(0, 18, 0, 0)
122 if len(group[1]) == 1:
123 box.setAlignment(Qt.AlignHCenter)
126 box.setContentsMargins(0, 0, 0, 0)
129 layout = QHBoxLayout()
131 layout.setContentsMargins(0, 0, 0, 0)
136 except AttributeError
as e:
142 raise Exception(
"All widgets must be a subclass of QWidget!")
145 box.setLayout(layout)