当前位置: 首页 > news >正文

南阳手机网站制作建设网站工作室

南阳手机网站制作,建设网站工作室,wordpress双语版,工作室需要营业执照吗QScintilla 安装示例代码参考链接 安装 最近发现了一个有趣的库#xff0c;qt的插件库#xff0c;之前一直以为显示代码时是重写QTextEdit来实现的#xff0c;结果qt有现成的一个库来显示这些东西#xff0c;在此记录一下 # 安装 QScintilla pip install QScintilla示例代码… QScintilla 安装示例代码参考链接 安装 最近发现了一个有趣的库qt的插件库之前一直以为显示代码时是重写QTextEdit来实现的结果qt有现成的一个库来显示这些东西在此记录一下 # 安装 QScintilla pip install QScintilla示例代码 import sysfrom PyQt5.Qsci import QsciLexerPython, QsciScintilla from PyQt5.Qt import *class MyQsciLexerPython(QsciLexerPython):def __init__(self, parentNone):super().__init__(parent)self.setColor(QColor(0, 0, 0)) # 设置默认的字体颜色self.setPaper(QColor(255, 255, 255)) # 设置底色self.setColor(QColor(#B0171F), QsciLexerPython.Keyword)self.setColor(QColor(#008000), QsciLexerPython.Comment) # 块注释 的颜色self.setColor(QColor(#007f7f), QsciLexerPython.Number) # 数字 的颜色self.setColor(QColor(#ff00ff), QsciLexerPython.DoubleQuotedString) # 双引号字符串的颜色self.setColor(QColor(#ff00ff), QsciLexerPython.SingleQuotedString) # 单引号字符的颜色self.setColor(QColor(#191970), QsciLexerPython.Operator)self.setColor(QColor(#000000), QsciLexerPython.Identifier) # 可识别字符的颜色这个范围很广包含了关键词函数名所以要取消这句self.setColor(QColor(#0000FF), QsciLexerPython.UnclosedString) # 未完成输入的字符串的颜色class MyQsciScintilla(QsciScintilla):def __init__(self, parentNone):super().__init__(parent)# 1.设置文档的编码格式为 “utf8” 换行符为 windows 【可选linuxMac】self.setUtf8(True)self.setEolMode(QsciScintilla.SC_EOL_CRLF) # 文件中的每一行都以EOL字符结尾换行符为 \r \n# 2.设置括号匹配模式self.setBraceMatching(QsciScintilla.StrictBraceMatch) ## 3.设置 Tab 键功能self.setIndentationsUseTabs(True) # 行首缩进采用Tab键反向缩进是Shift Tabself.setIndentationWidth(4) # 行首缩进宽度为4个空格self.setIndentationGuides(True) # 显示虚线垂直线的方式来指示缩进self.setTabIndents(True) # 编辑器将行首第一个非空格字符推送到下一个缩进级别self.setAutoIndent(True) # 插入新行时自动缩进将光标推送到与前一个相同的缩进级别self.setBackspaceUnindents(True)self.setTabWidth(4) # Tab 等于 4 个空格# 4.设置光标self.setCaretWidth(2) # 光标宽度以像素为单位0表示不显示光标self.setCaretForegroundColor(QColor(darkCyan)) # 光标颜色self.setCaretLineVisible(True) # 是否高亮显示光标所在行self.setCaretLineBackgroundColor(QColor(#FFCFCF)) # 光标所在行的底色# 5.设置页边特性。 这里有3种Margin[0]行号 [1]改动标识 [2]代码折叠# 5.1 设置行号font QFont()# font.setFamilies([Segoe UI, Microsoft YaHei, PingFang SC])font.setFamily(JetBrains Mono)font.setPixelSize(14)self.setFont(font)# self.setMarginsFont(font) # 行号字体self.setMarginLineNumbers(0, True) # 设置标号为0的页边显示行号self.setMarginWidth(0, 40) # 行号宽度self.setMarkerForegroundColor(QColor(#FFFFFF), 0)# 5.2 设置改动标记self.setMarginType(1, QsciScintilla.SymbolMargin) # 设置标号为1的页边用于显示改动标记self.setMarginWidth(1, 0000) # 改动标记占用的宽度# img QPixmap(:/leftside.png) # 改动标记图标大小是48 x 48# sym_1 img.scaled(QSize(16, 16)) # 图标缩小为 16 x 16# self.markerDefine(sym_1, 0)# self.setMarginMarkerMask(1, 0b1111)self.setMarkerForegroundColor(QColor(#ee1111), 1) # 00ff00# 5.3 设置代码自动折叠区域self.setFolding(QsciScintilla.PlainFoldStyle)self.setMarginWidth(2, 12)# 5.3.1 设置代码折叠和展开时的页边标记 - self.markerDefine(QsciScintilla.Minus, QsciScintilla.SC_MARKNUM_FOLDEROPEN)self.markerDefine(QsciScintilla.Plus, QsciScintilla.SC_MARKNUM_FOLDER)self.markerDefine(QsciScintilla.Minus, QsciScintilla.SC_MARKNUM_FOLDEROPENMID)self.markerDefine(QsciScintilla.Plus, QsciScintilla.SC_MARKNUM_FOLDEREND)# 5.3.2 设置代码折叠后 的颜色FFFFFFself.setMarkerBackgroundColor(QColor(#FFBCBC), QsciScintilla.SC_MARKNUM_FOLDEREND)self.setMarkerForegroundColor(QColor(red), QsciScintilla.SC_MARKNUM_FOLDEREND)class Window(QWidget):def __init__(self, parentNone):super().__init__(parent)self.vBox QVBoxLayout(self)self.editor MyQsciScintilla(self)self.lexer MyQsciLexerPython(self.editor)self.editor.setLexer(self.lexer)self.vBox.addWidget(self.editor)self.setFileText(MCSL2.py)def setFileText(self, fileName: str):with open(fileName, r, encodingutf-8) as f:self.editor.setText(f.read())if __name__ __main__:QApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)app QApplication(sys.argv)app.setQuitOnLastWindowClosed(True)demo Window()demo.resize(800, 600)demo.show()sys.exit(app.exec_()) 参考链接 PYQT5:基于QsciScintilla的代码编辑器分析5–多文档编辑区介绍 QScintilla入门指南之编辑器设置
http://www.dnsts.com.cn/news/174456.html

相关文章:

  • 上海网站建设价字体分辨网站
  • 网站建设推广平台有哪些企业电子商务网站建设评估试验
  • 做网站用的什么编程语言建网站公司销售
  • 网站代运营做哪些百度经验首页官网
  • app拉新项目一手渠道商seo综合查询可以关了吗
  • 常州免费做网站windows 2008 iis怎么搭建网站
  • 昆明做网站首选互维wordpress双语主题
  • 有可以花钱让人做问券的网站吗网站建设合同属于什么类别
  • 网站空间配置所见即所得的网站开发软件
  • dede网站地图制作王野电动车
  • jq网站特效插件下载做网站需要备注号码
  • 焦作网站建设公司wordpress写文章如何添加锚文本
  • 人才市场网站源码青岛栈桥介绍
  • 接效果图做网站网站开发和系统开发区别
  • 个人资料库网站怎么做安徽搜索引擎优化
  • 公司网站建设宣传报道稿件wordpress x 主题
  • 购物网站如何建设网页制作课件
  • 青岛 两学一做 网站优化推广
  • 茂名网站建设公司哪个好网站安全维护怎么做
  • 炫酷网站首页wordpress的ftp設置
  • 莱芜网站建设sikesoft网站一年了百度不收录
  • 做五金生意什么网站做比较好windows主机 wordpress 防盗链
  • 企业网站建设方案百度文库网站域名后缀代表什么
  • python做的网站漏洞海南省住房和城乡建设厅网站电脑版
  • 商务网站前台模板网站栏目做树形结构图
  • 作品集模板网站注册建设通网站首页
  • 镇江网站关键字优化公司网推赚钱项目
  • 网站制作合作协议建立网站赚钱
  • 商城手机网站建设手机网站域名m打头
  • 旅游网站开发的意义相关资料优秀网站推广方案