1 from builtins
import range
4 from PyQt4.QtCore import Qt, SIGNAL, QCoreApplication, QEvent, QSize
5 from PyQt4.QtGui import QSplitter, QColor, QPalette, QToolBar, QSizePolicy, QWidget, QFrame, QHeaderView, QStandardItemModel, QVBoxLayout
11 """ A Tab with a QSplitter and a function to create the PropertyView. 13 The Tab is split vertically and within horizontally. QWidgets can be added 14 to verticalSplitter() and horizontalSplitter(). In the constructor 15 one can choose whether the PropertyView shall be on top level or inside 16 the horizontalSplitter(). 18 def __init__(self, parent=None, topLevelPropertyView=False):
19 logging.debug(__name__ +
": __init__")
21 AbstractTab.__init__(self)
23 QSplitter.__init__(self, Qt.Horizontal, parent)
26 QSplitter.__init__(self, Qt.Vertical, parent)
43 """ Implement this function if you want to react on size changes invoked by the vertical splitter. 48 return self._horizontalSplitter
51 """ Implement this function if you want to react on size changes invoked by the horizontal splitter. 57 index = self.verticalSplitter().
count()
58 self._toolBar = SplitterToolBar()
59 self.verticalSplitter().insertWidget(index,self._toolBar)
60 self.verticalSplitter().setCollapsible(index,
False)
61 self._toolBar.setFixedHeight(20)
68 AbstractTab.setController(self, controller)
70 self._propertyView.setReadOnly(
not self.
controller().isEditable())
74 """ Creates PropertyView object, adds it to this tab and makes it available via propertyView(). 83 """ Returns PropertyView object. See createPropertyView(). 88 """ Call close if tab is not embedded in TabWidget 99 """ Call tabChanged if window is activated. 102 if event.type()==QEvent.WindowActivate:
103 QCoreApplication.instance().tabChanged()
104 return QSplitter.event(self,event)
108 """ A vertical toolbar which can be split up in sections. 110 The toolbar can be placed in the verticalSplitter() of the SplitterTab 111 to separate two parts. The toolbar can hold buttons to control its 122 QToolBar.__init__(self, parent)
123 self.layout().setSpacing(0)
126 spacer = QWidget(self)
127 spacer.setFixedSize(width, self.iconSize().height())
131 if alignment ==
None:
137 leftSpacerAction = self.addWidget(leftSpacer)
138 rightSpacerAction = self.addWidget(rightSpacer)
139 section = {
"leftSpacer": leftSpacer,
"leftSpacerAction": leftSpacerAction,
140 "contentList": contentList,
141 "rightSpacer": rightSpacer,
"rightSpacerAction": rightSpacerAction,
142 "alignment": alignment}
144 self._sections.append(section)
151 logging.error(self.__class__.__name__ +
": addWidgetToSection() - Unknown section number %d. Aborting..." % section)
156 self.insertWidget(self.
_sections[section][
"rightSpacerAction"], widget)
162 """ sizes is list of widths for section spacers. 168 for content
in section[
"contentList"]:
169 contentsWidth += content.width() + self.layout().spacing() + 1
171 rightWidth = sizes[i] - contentsWidth
174 contentsWidth += self.layout().spacing() * 2
176 leftWidth = sizes[i] - contentsWidth
179 leftWidth = 0.5 * (sizes[i] - contentsWidth)
180 rightWidth = leftWidth
181 section[
"leftSpacer"].setFixedSize(
max(0, leftWidth), self.iconSize().height())
182 section[
"rightSpacer"].setFixedSize(
max(0, rightWidth), self.iconSize().height())
185 for button
in toolBox.toggleButtons():
189 QToolBar.showEvent(self, event)
def closeEvent(self, event)
def addWidgetToSection(self, widget, section)
def setSectionSizes(self, sizes)
def horizontalSplitter(self)
def setController(self, controller)
def verticalSplitterMovedSlot(self, pos, index)
def __init__(self, parent=None)
def showEvent(self, event)
def addSection(self, alignment=None)
def createPropertyView(self)
def createToolBar(self, index=None)
def __init__(self, parent=None, topLevelPropertyView=False)
def verticalSplitter(self)
def _createSpacer(self, width=0)
def horizontalSplitterMovedSlot(self, pos, index)
def takeToolBoxContainerButtons(self, toolBox, section)