本文整理汇总了Python中PyQt5.QtWidgets.QSplitter.closestLegalPosition方法的典型用法代码示例。如果您正苦于以下问题:Python QSplitter.closestLegalPosition方法的具体用法?Python QSplitter.closestLegalPosition怎么用?Python QSplitter.closestLegalPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QSplitter
的用法示例。
在下文中一共展示了QSplitter.closestLegalPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: QuadView
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import closestLegalPosition [as 别名]
#.........这里部分代码省略.........
wRight = max(w2)
if wLeft > wRight and wLeft > w // 2:
wRight = w - wLeft
elif wRight >= wLeft and wRight > w // 2:
wLeft = w - wRight
else:
wLeft = w // 2
wRight = w // 2
self.splitHorizontal1.setSizes([wLeft, wRight])
self.splitHorizontal2.setSizes([wLeft, wRight])
def eventFilter(self, obj, event):
if event.type() in [QEvent.WindowActivate, QEvent.Show]:
self._synchronizeSplitter()
return False
def _synchronizeSplitter(self):
sizes1 = self.splitHorizontal1.sizes()
sizes2 = self.splitHorizontal2.sizes()
if len(sizes1) > 0 and sizes1[0] > 0:
self.splitHorizontal2.setSizes(sizes1)
elif len(sizes2) > 0 and sizes2[0] > 0:
self.splitHorizontal1.setSizes(sizes2)
def resizeEvent(self, event):
QWidget.resizeEvent(self, event)
self._synchronizeSplitter()
def horizontalSplitterMoved(self, x, y):
if self.splitHorizontal1.count() != 2 or self.splitHorizontal2.count() != 2:
return
sizes = self.splitHorizontal1.sizes()
# What. Nr2
if self.splitHorizontal2.closestLegalPosition(x, y) < self.splitHorizontal2.closestLegalPosition(x, y):
sizeLeft = self.splitHorizontal1.closestLegalPosition(x, y)
else:
sizeLeft = self.splitHorizontal2.closestLegalPosition(x, y)
sizeRight = sizes[0] + sizes[1] - sizeLeft
sizes = [sizeLeft, sizeRight]
self.splitHorizontal1.setSizes(sizes)
self.splitHorizontal2.setSizes(sizes)
def addStatusBar(self, bar):
self.statusBar = bar
self.layout.addLayout(self.statusBar)
def setGrayScaleToQuadStatusBar(self, gray):
self.quadViewStatusBar.setGrayScale(gray)
def setMouseCoordsToQuadStatusBar(self, x, y, z):
self.quadViewStatusBar.setMouseCoords(x, y, z)
def ensureMaximized(self, axis):
"""
Maximize the view for the given axis if it isn't already maximized.
"""
axisDict = {
0: self.dock2_ofSplitHorizontal1, # x
1: self.dock1_ofSplitHorizontal2, # y
2: self.dock1_ofSplitHorizontal1,
} # z
if not axisDict[axis]._isMaximized:
self.switchMinMax(axis)