24 from PyQt5
import QtCore, QtWidgets, QtGui
27 """QWidget with a ToolBar and a show area.
29 This abstract QWidget has a toolbar and a show area. Whenever a button of the tool bar is pressed, the Widget corresponding to the button's value is shown in the show area.
32 QtWidgets.QWidget.__init__(self, parent)
37 self.setMinimumSize(QtCore.QSize(250, 200))
39 self.
gridLayoutgridLayout.setHorizontalSpacing(0)
40 self.
gridLayoutgridLayout.setVerticalSpacing(0)
41 self.
gridLayoutgridLayout.setContentsMargins(0,0,0,0)
44 self.
tool_bar_tool_bar_.setIconSize(QtCore.QSize(16, 16))
59 """Updates the active widget of the show area.
61 This method calls the Update method of the active widget.
65 if hasattr(widget,
"Update"):
70 """Adds a Widget to this Options Widget.
72 The Widget must have a identifier. If another Widget has the same identifier,
73 the old widget will be removed and the new widget gets the identifier.
74 Returns True, if widget is added. Otherwise it returns False
76 if isinstance(widget, QtWidgets.QWidget)
and ident
is not None:
79 elif hasattr(widget,
"GetText"):
80 string = widget.GetText()
85 action = self.
tool_bar_tool_bar_.addAction(ident)
86 action.setIcon(QtGui.QIcon(ident))
87 action.setToolTip(string)
89 action.setData(QtCore.QVariant(pair))
90 action.setCheckable(
True);
98 """This abstract method is called whenever the View is updated.
100 This abstract method must be implemented by all subclasses.
101 It can be used to do something ;-) whenever the combobox changes its value.
103 raise NotImplementedError(
"Subclasses must define OnComboChange()")
109 if(hasattr(item,
"minimumHeight")):
110 height=item.minimumHeight()
111 if(hasattr(item,
"minimumWidth")):
112 width=item.minimumWidth()
113 self.setMinimumSize(width,self.
tool_bar_tool_bar_.height()+height)
114 if(hasattr(self.
parent_parent_,
"DoResize")):
118 """Change Current Selected Item.
120 Shows the widget which corresponds to the action in the show area.
126 widget = action.data()[1]
128 if hasattr(widget,
"Update"):
136 def __GetCurrentWidget(self):
141 QtWidgets.QWidget.setEnabled(self, bool)