24 from PyQt5
import QtCore, QtWidgets
27 """QWidget with a Combobox and a show area.
29 This abstract QWidget has a Combobox and a show area. Whenever the value of
30 the Combobox changes, the Widget corresponding to the Combobox's value is
31 shown in the show area.
34 QtWidgets.QWidget.__init__(self, parent)
40 self.
grid_layout_grid_layout_.setContentsMargins(0,0,0,0)
55 """Updates the ComboOptionsWidget and the active widget of the show area.
57 This method calls the Update method of the active widget.
62 """Adds a Widget to this Options Widget.
64 The Widget must have a identifier. If another Widget has the same identifier,
65 the old widget will be removed and the new widget gets the identifier.
66 Returns True, if widget is added. Otherwise it returns False
68 if isinstance(widget, QtWidgets.QWidget)
and ident
is not None:
69 if hasattr(widget,
"GetText"):
70 string = widget.GetText()
77 self.
combo_box_combo_box_.addItem(string, QtCore.QVariant(qpair))
88 """This abstract method is called whenever the View is updated.
90 This abstract method must be implemented by all subclasses.
91 It can be used to do something ;-) whenever the combobox changes its value.
93 raise NotImplementedError(
"Subclasses must define OnComboChange()")
100 Change Current Selected Item.
102 Shows the widget which corresponds to the ident in the show area. If ident
103 is not valid, nothing happens.
106 if(i>=0)
and self.
combo_box_combo_box_.currentIndex() != i:
114 if(self.
combo_box_combo_box_.currentIndex() >= 0):
122 if(hasattr(item,
"minimumHeight")):
123 height=item.minimumHeight()
124 if(hasattr(item,
"minimumWidth")):
125 width=item.minimumWidth()
126 self.setMinimumSize(width,40+height)
127 if(hasattr(self.
parent_parent_,
"DoResize")):
131 def __UpdateView(self, item):
137 def __GetIndex(self, ident):
138 for i
in range(self.
combo_box_combo_box_.count()):
144 def __GetCurrentPair(self):
145 current_index = self.
combo_box_combo_box_.currentIndex()
146 return self.
combo_box_combo_box_.itemData(current_index)
150 QtWidgets.QWidget.setEnabled(self, bool)
151 for i
in range(self.
combo_box_combo_box_.count()):