添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
    # 视图-浏览器字体/大小设置
    def browser_word_style(self):
        (font, ok) = QFontDialog.getFont(self.textBrowser.font(), self, "浏览器字体/大小设置")
        if font:
            self.textBrowser.setFont(font)
    # 视图-浏览器字体颜色设置
    def browser_word_color(self):
        col = QColorDialog.getColor(self.textBrowser.textColor(), self, "浏览器字体颜色设置")
        if col.isValid():
            self.textBrowser.setTextColor(col)
    # 视图-浏览器背景颜色设置
    def browser_background_color(self):
        col = QColorDialog.getColor(self.textBrowser.textColor(), self, "浏览器背景颜色设置")
        if col.isValid():
            self.textBrowser.setStyleSheet(
                "background-color: rgb({}, {}, {});".format(col.red(), col.green(), col.blue()))

代码分析:

(font, ok) = QFontDialog.getFont(self.textBrowser.font(), self, "浏览器字体/大小设置")

getFont(initial[,parent=None[,title=""[,options=QFontDialog.FontDialogOptions()]]])

参数类型:

initial - PySide2.QtGui.QFont

parent - PySide2.QtWidgets.QWidget

title - str

options - FontDialogOptions

返回类型:

PyTuple

col = QColorDialog.getColor(self.textBrowser.textColor(), self, "浏览器背景颜色设置")

getColor([initial=Qt.white[,parent=None[,title=""[,options=QColorDialog.ColorDialogOptions()]]]])

参数类型:

initial - PySide2.QtGui.QColor

parent - PySide2.QtWidgets.QWidget

title - str

options - ColorDialogOptions

返回类型:

PySide2.QtGui.QColor

self.textBrowser.setStyleSheet(
                "background-color: rgb({}, {}, {});".format(col.red(), col.green(), col.blue()))

QColor类提供了获得不同颜色分量参数的方法,我们根据格式获得不同的参数就可以了。rgb为RGB彩色模式。

以前-好记性不如烂笔头 现在-好记性不如烂键盘