Python PyQt5.QtWidgets 模块,QScrollBar() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用PyQt5.QtWidgets.QScrollBar()

项目:uPyLoader    作者:BetaRavener    | 项目源码 | 文件源码
def update_content(self):
        new_content = self.terminal.read()
        new_content = self.process_backspaces(new_content)
        if not new_content:
            return

        scrollbar = self.outputTextEdit.verticalScrollBar()
        assert isinstance(scrollbar, QScrollBar)
        # Preserve scroll while updating content
        current_scroll = scrollbar.value()

        prev_cursor = self.outputTextEdit.textCursor()
        self.outputTextEdit.moveCursor(QTextCursor.End)
        # Use any backspaces that were left in input to delete text
        cut = 0
        for x in new_content:
            if x != "\b":
                break
            self.outputTextEdit.textCursor().deletePreviousChar()
            cut += 1
        self.outputTextEdit.insertPlainText(new_content[cut:])
        self.outputTextEdit.setTextCursor(prev_cursor)

        if self._auto_scroll:
            scrollbar.setValue(scrollbar.maximum())
        else:
            scrollbar.setValue(current_scroll)
项目:uPyLoader    作者:BetaRavener    | 项目源码 | 文件源码
def _update_output(self):
        scrollbar = self.outputEdit.verticalScrollBar()
        assert isinstance(scrollbar, QScrollBar)
        # Preserve scroll while updating content
        current_scroll = scrollbar.value()
        scrolling = scrollbar.isSliderDown()

        with self._flash_output_mutex:
            self.outputEdit.setPlainText(self._flash_output.decode('utf-8', errors="ignore"))

        if not scrolling:
            scrollbar.setValue(scrollbar.maximum())
        else:
            scrollbar.setValue(current_scroll)
项目:uPyLoader    作者:BetaRavener    | 项目源码 | 文件源码
def _scroll_released(self):
        if not self.autoscrollCheckBox.isChecked():
            self._auto_scroll = False
            return

        scrollbar = self.outputTextEdit.verticalScrollBar()
        assert isinstance(scrollbar, QScrollBar)
        current_scroll = scrollbar.value()
        self._auto_scroll = current_scroll >= scrollbar.maximum()
项目:PointlessMaker    作者:aboood40091    | 项目源码 | 文件源码
def __init__(self, scene, parent):
        super().__init__(scene, parent)

        self.setAlignment(Qt.AlignLeft | Qt.AlignTop)
        self.setDragMode(QtWidgets.QGraphicsView.RubberBandDrag)
        self.setMouseTracking(True)
        self.YScrollBar = QtWidgets.QScrollBar(Qt.Vertical, parent)
        self.XScrollBar = QtWidgets.QScrollBar(Qt.Horizontal, parent)
        self.setVerticalScrollBar(self.YScrollBar)
        self.setHorizontalScrollBar(self.XScrollBar)

        self.currentobj = None

        self.setRenderHints(QtGui.QPainter.Antialiasing | QtGui.QPainter.SmoothPixmapTransform)
项目:OpenTutorials_PyQt    作者:RavenKyu    | 项目源码 | 文件源码
def init_widget(self):
        self.setWindowTitle("Hello World")
        form_lbx = QBoxLayout(QBoxLayout.TopToBottom, parent=self)
        self.setLayout(form_lbx)

        pgsb = QProgressBar()
        vscrb = QScrollBar(orientation=Qt.Horizontal)
        vscrb.setRange(0, 100)
        vscrb.valueChanged.connect(pgsb.setValue)

        form_lbx.addWidget(pgsb)
        form_lbx.addWidget(vscrb)