7 """ Container for widgets which can be shown or hidden by a row of toggle buttons at the bottom of the container 9 The container uses a vertical QSplitter object to show added widgets. 12 HIDE_LAST_TOGGLE_BUTTON =
True 17 def __init__(self, parent=None, containerType=None):
20 logging.debug(__name__ +
": __init__()")
21 QWidget.__init__(self, parent)
32 self.setLayout(QVBoxLayout())
33 self.layout().setSpacing(0)
34 self.layout().setContentsMargins(0, 0, 0, 0)
40 self._buttonLayout.addStretch(2)
41 self._buttonLayout.setSpacing(0)
43 self.layout().addStretch(0.5)
50 """ Influences visibility of last visible toggle button. 52 If hide is True toggle buttons are only shown if there is more than one widget selectable. 53 In this case the ToolBoxContainer behaves like a normal widget. 54 If hide if False the toggle button is also show if there is only one widget selectable. 59 """ Returns splitter containing widgets. 67 """ Adds widget to tool box. 70 self._splitter.addWidget(widget)
72 self.layout().insertWidget(len(self.
_toolboxList), widget, stretch)
73 self._toolboxList.append(widget)
74 toggleButton = QToolButton()
75 toggleButton.setCheckable(
True)
76 toggleButton.setChecked(
True)
77 toggleButton.setText(
"v")
78 toggleButton.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
80 self._buttonLayout.addWidget(toggleButton, 0, Qt.AlignRight)
81 self._toggleButtons.append(toggleButton)
87 widget.setVisible(show)
88 self.
_toggleButtons[self._toolboxList.index(widget)].setVisible(show)
109 """ Returns list of indices of toggle buttons which are visible. 114 """ Returns list of indices of tool box widgets which are visible. 119 """ Returns list of indices of entries in given list which are visible. 121 It is assumed list entries have boolean function isVisible() (e.g. QWidget). 124 for i
in range(len(list)):
125 if list[i].isVisible():
130 """ Slot for showing and hinding widgets when toggle buttons are pressed. 133 index = self._toggleButtons.index(self.sender())
137 self.sender().setText(
"^")
140 self.sender().setText(
"v")