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.gridLayout.setHorizontalSpacing(0)
40 self.gridLayout.setVerticalSpacing(0)
41 self.gridLayout.setContentsMargins(0,0,0,0)
42 self.gridLayout.setSpacing(0)
44 self.tool_bar_.setIconSize(QtCore.QSize(16, 16))
45 self.gridLayout.addWidget(self.
tool_bar_, 0, 0, 1, 1)
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()
84 self.stackedWidget.addWidget(widget)
85 action = self.tool_bar_.addAction(ident)
86 action.setIcon(QtGui.QIcon(ident))
87 action.setToolTip(string)
89 action.setData(QtCore.QVariant(pair))
90 action.setCheckable(
True);
93 self.actions_.append(action)
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_.height()+height)
114 if(hasattr(self.
parent_,
"DoResize")):
115 self.parent_.DoResize()
118 """Change Current Selected Item.
120 Shows the widget which corresponds to the action in the show area.
123 self.current_action_.setChecked(
False)
126 widget = action.data()[1]
127 self.stackedWidget.setCurrentWidget(widget)
128 if hasattr(widget,
"Update"):
131 self.current_action_.setChecked(
True)
136 def __GetCurrentWidget(self):
137 return self.stackedWidget.currentWidget();
141 QtWidgets.QWidget.setEnabled(self, bool)