当前位置: 首页>>代码示例>>Python>>正文


Python QSplitter.closestLegalPosition方法代码示例

本文整理汇总了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)
开发者ID:ilastik,项目名称:volumina,代码行数:70,代码来源:quadsplitter.py


注:本文中的PyQt5.QtWidgets.QSplitter.closestLegalPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。