python类QScrollBar()的实例源码

terminal_dialog.py 文件源码 项目:uPyLoader 作者: BetaRavener 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)
flash_dialog.py 文件源码 项目:uPyLoader 作者: BetaRavener 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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)
terminal_dialog.py 文件源码 项目:uPyLoader 作者: BetaRavener 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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()
widgets.py 文件源码 项目:PointlessMaker 作者: aboood40091 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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)
QProgressBar_00_basic.py 文件源码 项目:OpenTutorials_PyQt 作者: RavenKyu 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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)


问题


面经


文章

微信
公众号

扫码关注公众号