qscieditor.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:qturtle 作者: Transpyler 项目源码 文件源码
def setAllFonts(self, family='monospace', size=10, fixedpitch=True):
        """Set the font of all visible elements in the text editor.

        This syncronizes the font in the main text area with the margins and
        calltips.
        """

        self.fontfamily = family
        self.fontsize = size
        self.fontfixedpitch = True

        # Configure editor font size
        font = QFont()
        font.setFamily(family)
        font.setFixedPitch(fixedpitch)
        font.setPointSize(size)
        self.setFont(font)

        # Margin 0 is used for line numbers
        fontmetrics = QtGui.QFontMetrics(font)
        self.setMarginsFont(font)
        self.setMarginWidth(0, fontmetrics.width('___') + 0)
        self.setMarginWidth(1, 0)
        self.setMarginLineNumbers(0, True)

        # Change lexer font
        bfamily = bytes(family, encoding='utf8')
        lexer = self.lexer()
        if lexer is not None:
            font_bold = QFont(font)
            font_bold.setBold(True)
            for style in self.LEXER_STYLES.values():
                if style in self.BOLD_STYLES:
                    lexer.setFont(font_bold, style)
                else:
                    lexer.setFont(font, style)
            self.SendScintilla(Qsci.QsciScintilla.SCI_STYLESETFONT, 1, bfamily)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号