3 from PyQt4.QtCore import Qt, SIGNAL, QCoreApplication, QEvent, QSize
4 from PyQt4.QtGui import QSplitter, QColor, QPalette, QToolBar, QSizePolicy, QWidget, QFrame, QHeaderView, QStandardItemModel, QVBoxLayout
10 """ A Tab with a QSplitter and a function to create the PropertyView. 12 The Tab is split vertically and within horizontally. QWidgets can be added 13 to verticalSplitter() and horizontalSplitter(). In the constructor 14 one can choose whether the PropertyView shall be on top level or inside 15 the horizontalSplitter(). 17 def __init__(self, parent=None, topLevelPropertyView=False):
18 logging.debug(__name__ +
": __init__")
20 AbstractTab.__init__(self)
22 QSplitter.__init__(self, Qt.Horizontal, parent)
25 QSplitter.__init__(self, Qt.Vertical, parent)
42 """ Implement this function if you want to react on size changes invoked by the vertical splitter. 47 return self._horizontalSplitter
50 """ Implement this function if you want to react on size changes invoked by the horizontal splitter. 56 index = self.verticalSplitter().
count()
57 self._toolBar = SplitterToolBar()
58 self.verticalSplitter().insertWidget(index,self._toolBar)
59 self.verticalSplitter().setCollapsible(index,
False)
60 self._toolBar.setFixedHeight(20)
67 AbstractTab.setController(self, controller)
69 self._propertyView.setReadOnly(
not self.
controller().isEditable())
73 """ Creates PropertyView object, adds it to this tab and makes it available via propertyView(). 82 """ Returns PropertyView object. See createPropertyView(). 87 """ Call close if tab is not embedded in TabWidget 98 """ Call tabChanged if window is activated. 101 if event.type()==QEvent.WindowActivate:
102 QCoreApplication.instance().tabChanged()
103 return QSplitter.event(self,event)
107 """ A vertical toolbar which can be split up in sections. 109 The toolbar can be placed in the verticalSplitter() of the SplitterTab 110 to separate two parts. The toolbar can hold buttons to control its 121 QToolBar.__init__(self, parent)
122 self.layout().setSpacing(0)
125 spacer = QWidget(self)
126 spacer.setFixedSize(width, self.iconSize().height())
130 if alignment ==
None:
131 alignment = self.ALIGNMENT_CENTER
136 leftSpacerAction = self.addWidget(leftSpacer)
137 rightSpacerAction = self.addWidget(rightSpacer)
138 section = {
"leftSpacer": leftSpacer,
"leftSpacerAction": leftSpacerAction,
139 "contentList": contentList,
140 "rightSpacer": rightSpacer,
"rightSpacerAction": rightSpacerAction,
141 "alignment": alignment}
143 self._sections.append(section)
150 logging.error(self.__class__.__name__ +
": addWidgetToSection() - Unknown section number %d. Aborting..." % section)
155 self.insertWidget(self.
_sections[section][
"rightSpacerAction"], widget)
161 """ sizes is list of widths for section spacers. 167 for content
in section[
"contentList"]:
168 contentsWidth += content.width() + self.layout().spacing() + 1
169 if section[
"alignment"] == self.ALIGNMENT_LEFT:
170 rightWidth = sizes[i] - contentsWidth
172 elif section[
"alignment"] == self.ALIGNMENT_RIGHT:
173 contentsWidth += self.layout().spacing() * 2
175 leftWidth = sizes[i] - contentsWidth
178 leftWidth = 0.5 * (sizes[i] - contentsWidth)
179 rightWidth = leftWidth
180 section[
"leftSpacer"].setFixedSize(
max(0, leftWidth), self.iconSize().height())
181 section[
"rightSpacer"].setFixedSize(
max(0, rightWidth), self.iconSize().height())
184 for button
in toolBox.toggleButtons():
188 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)