24 from PyQt4
import QtCore, 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 QtGui.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.setMargin(0)
43 self.gridLayout.setSpacing(0)
45 self.tool_bar_.setIconSize(QtCore.QSize(16, 16))
46 self.gridLayout.addWidget(self.
tool_bar_, 0, 0, 1, 1)
60 """Updates the active widget of the show area.
62 This method calls the Update method of the active widget.
66 if hasattr(widget,
"Update"):
71 """Adds a Widget to this Options Widget.
73 The Widget must have a identifier. If another Widget has the same identifier,
74 the old widget will be removed and the new widget gets the identifier.
75 Returns True, if widget is added. Otherwise it returns False
77 if isinstance(widget, QtGui.QWidget)
and ident
is not None:
79 string = QtCore.QString(text)
80 elif hasattr(widget,
"GetText"):
81 string = QtCore.QString(widget.GetText())
83 string = QtCore.QString(ident)
85 self.stackedWidget.addWidget(widget)
86 action = self.tool_bar_.addAction(ident)
87 action.setIcon(QtGui.QIcon(ident))
88 action.setToolTip(string)
90 action.setData(QtCore.QVariant(pair))
91 action.setCheckable(
True);
94 self.actions_.append(action)
99 """This abstract method is called whenever the View is updated.
101 This abstract method must be implemented by all subclasses.
102 It can be used to do something ;-) whenever the combobox changes its value.
104 raise NotImplementedError,
"Subclasses must define OnComboChange()"
110 if(hasattr(item,
"minimumHeight")):
111 height=item.minimumHeight()
112 if(hasattr(item,
"minimumWidth")):
113 width=item.minimumWidth()
114 self.setMinimumSize(width,self.tool_bar_.height()+height)
115 if(hasattr(self.
parent_,
"DoResize")):
116 self.parent_.DoResize()
119 """Change Current Selected Item.
121 Shows the widget which corresponds to the action in the show area.
124 self.current_action_.setChecked(
False)
127 widget = action.data().toPyObject()[1]
128 self.stackedWidget.setCurrentWidget(widget)
129 if hasattr(widget,
"Update"):
132 self.current_action_.setChecked(
True)
137 def __GetCurrentWidget(self):
138 return self.stackedWidget.currentWidget();
142 QtGui.QWidget.setEnabled(self, bool)