本文整理汇总了Python中PyQt5.QtWidgets.QSplitter.handle方法的典型用法代码示例。如果您正苦于以下问题:Python QSplitter.handle方法的具体用法?Python QSplitter.handle怎么用?Python QSplitter.handle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QSplitter
的用法示例。
在下文中一共展示了QSplitter.handle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SubTabWidget
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import handle [as 别名]
class SubTabWidget(QWidget):
_tabChanged = pyqtSignal(int, name = "tabChanged")
def __init__(self, subtitleData, videoWidget, parent = None):
super(SubTabWidget, self).__init__(parent)
self._subtitleData = subtitleData
self.__initTabWidget(videoWidget)
def __initTabWidget(self, videoWidget):
settings = SubSettings()
mainLayout = QVBoxLayout(self)
mainLayout.setContentsMargins(0, 0, 0, 0)
mainLayout.setSpacing(0)
#TabBar
self.tabBar = QTabBar(self)
# Splitter (bookmarks + pages)
self.splitter = QSplitter(self)
self.splitter.setObjectName("sidebar_splitter")
self._toolbox = ToolBox(self._subtitleData, self)
self._toolbox.setObjectName("sidebar")
self._toolbox.setMinimumWidth(100)
self._toolbox.addTool(Details(self._subtitleData, self))
self._toolbox.addTool(Synchronizer(videoWidget, self._subtitleData, self))
self._toolbox.addTool(History(self))
self.rightWidget = QWidget()
rightLayout = QGridLayout()
rightLayout.setContentsMargins(0, 0, 0, 0)
self.rightWidget.setLayout(rightLayout)
self._mainTab = FileList(_("Subtitles"), self._subtitleData, self)
self.pages = QStackedWidget(self)
rightLayout.addWidget(self.pages, 0, 0)
self.tabBar.addTab(self._mainTab.name)
self.pages.addWidget(self._mainTab)
self.splitter.addWidget(self._toolbox)
self.splitter.addWidget(self.rightWidget)
self.__drawSplitterHandle(1)
# Setting widgets
mainLayout.addWidget(self.tabBar)
mainLayout.addWidget(self.splitter)
# Widgets settings
self.tabBar.setMovable(True)
self.tabBar.setTabsClosable(True)
self.tabBar.setExpanding(False)
# Don't resize left panel if it's not needed
leftWidgetIndex = self.splitter.indexOf(self._toolbox)
rightWidgetIndex = self.splitter.indexOf(self.rightWidget)
self.splitter.setStretchFactor(leftWidgetIndex, 0)
self.splitter.setStretchFactor(rightWidgetIndex, 1)
self.splitter.setCollapsible(leftWidgetIndex, False)
self.splitter.setSizes([250])
# Some signals
self.tabBar.currentChanged.connect(self.showTab)
self.tabBar.tabCloseRequested.connect(self.closeTab)
self.tabBar.tabMoved.connect(self.moveTab)
self._mainTab.requestOpen.connect(self.openTab)
self._mainTab.requestRemove.connect(self.removeFile)
self.tabChanged.connect(lambda i: self._toolbox.setContentFor(self.tab(i)))
self.setLayout(mainLayout)
def __addTab(self, filePath):
"""Returns existing tab index. Creates a new one if it isn't opened and returns its index
otherwise."""
for i in range(self.tabBar.count()):
widget = self.pages.widget(i)
if not widget.isStatic and filePath == widget.filePath:
return i
tab = SubtitleEditor(filePath, self._subtitleData, self)
newIndex = self.tabBar.addTab(self._createTabName(tab.name, tab.history.isClean()))
tab.history.cleanChanged.connect(
lambda clean: self._cleanStateForFileChanged(filePath, clean))
self.pages.addWidget(tab)
return newIndex
def __drawSplitterHandle(self, index):
splitterHandle = self.splitter.handle(index)
splitterLayout = QVBoxLayout(splitterHandle)
splitterLayout.setSpacing(0)
splitterLayout.setContentsMargins(0, 0, 0, 0)
line = QFrame(splitterHandle)
line.setFrameShape(QFrame.HLine)
line.setFrameShadow(QFrame.Sunken)
#.........这里部分代码省略.........