Stani 的 Python IDE 捆绑了许多有用的功能,但它不允许用户自定义语法着色。作者网站上的问答中提到:“除非您手动编辑 sm/wxp/stc.py,否则不支持更改颜色。”
用户想通过检查代码来寻找让 IDE 具有完美功能的方法。stc.py 文件似乎是作者对 Robin Dunn 的 wxPython 原始代码的修改。埋藏在所有事件处理中的似乎是决定各种语法颜色的代码。
用户只想将背景颜色改为黑色,将黑色文本改为白色,如果其他一切仍然显示在这两种新颜色下,用户很高兴。
2、解决方案
(1) 修改以下代码行:
def SetStyles(self):
# anti-aliasing
if hasattr(self,'SetUseAntiAliasing'):
self.SetUseAntiAliasing(True)
#INDICATOR STYLES FOR ERRORS (self.errorMark)
self.IndicatorSetStyle(2, wx_stc.STC_INDIC_SQUIGGLE)
self.IndicatorSetForeground(2, wx.RED)
#import dialogs.stcStyleEditor
if 1:#dialogs.stcStyleEditor.SetStyles(self, self.config):
self.StyleSetSpec(wx_stc.STC_P_DEFAULT, "face:%(mono)s,fore:#B0B0B0,size:%(size)d" % self.faces)
self.StyleClearAll()
# Global default styles for all languages B0B0B0= gray
self.StyleSetSpec(wx_stc.STC_STYLE_DEFAULT, "face:%(mono)s,fore:#B0B0B0,back:#00000,size:%(size)d" % self.faces)
self.StyleSetSpec(wx_stc.STC_STYLE_LINENUMBER, "back:#C0C0C0,face:%(mono)s,size:%(size)d" % self.faces)
self.StyleSetSpec(wx_stc.STC_STYLE_CONTROLCHAR, "face:%(mono)s,fore:#B0B0B0" % self.faces)
self.StyleSetSpec(wx_stc.STC_STYLE_BRACELIGHT, "fore:#B0B0B0,back:#0000FF,bold")
self.StyleSetSpec(wx_stc.STC_STYLE_BRACEBAD, "fore:#B0B0B0,back:#FF0000,bold")
# Python styles
# White space
self.StyleSetSpec(wx_stc.STC_P_DEFAULT, "face:%(mono)s,fore:#000000,back:#000000,size:%(size)d" % self.faces)
# Comment
self.StyleSetSpec(wx_stc.STC_P_COMMENTLINE, "face:%(mono)s,fore:#F70909,back:#000000,italic,size:%(size)d" % self.faces)
# Number
self.StyleSetSpec(wx_stc.STC_P_NUMBER, "face:%(mono)s,fore:#FFFFFF,size:%(size)d" % self.faces)
# String
self.StyleSetSpec(wx_stc.STC_P_STRING, "face:%(mono)s,fore:#34C640,size:%(size)d" % self.faces)
# Single quoted string
self.StyleSetSpec(wx_stc.STC_P_CHARACTER, "face:%(mono)s,fore:#43AB4E,size:%(size)d" % self.faces)
# Keyword (Class, def, etc.)
self.StyleSetSpec(wx_stc.STC_P_WORD, "face:%(mono)s,fore:#FF9100,bold,size:%(size)d" % self.faces)
# Triple quotes
self.StyleSetSpec(wx_stc.STC_P_TRIPLE, "face:%(mono)s,fore:#7F0000,size:%(size)d" % self.faces)
# Triple double quotes
self.StyleSetSpec(wx_stc.STC_P_TRIPLEDOUBLE, "face:%(mono)s,fore:#7F0000,size:%(size)d" % self.faces)
# Class name definition (Name of the class)
self.StyleSetSpec(wx_stc.STC_P_CLASSNAME, "face:%(mono)s,fore:#00AEFF,bold,size:%(size)d" % self.faces)
# Function or method name definition (bright blue = #0011FF)
self.StyleSetSpec(wx_stc.STC_P_DEFNAME, "face:%(mono)s,fore:#FFFF00,bold,size:%(size)d" % self.faces)
# Operators (+ - /)
self.StyleSetSpec(wx_stc.STC_P_OPERATOR, "face:%(mono)s,fore:#FFFFFF,bold,size:%(size)d" % self.faces)
# Identifiers (this was all the same color - > self.SetTopWindow(self.frame))
self.StyleSetSpec(wx_stc.STC_P_IDENTIFIER, "fore:#FFFFFF")
# Comment-blocks
self.StyleSetSpec(wx_stc.STC_P_COMMENTBLOCK, "face:%(mono)s,fore:#990000,back:#C0C0C0,italic,size:%(size)d" % self.faces)
# End of line where string is not closed
self.StyleSetSpec(wx_stc.STC_P_STRINGEOL, "face:%(mono)s,fore:#B1CCB0,face:%(mono)s,back:#E0C0E0,eol,size:%(size)d" % self.faces)
(2) 为了找到鼠标光标闪烁颜色的设置,需要查看 stc.py 中事件处理的其余部分。
(3) 这个应用程序不支持像在 Pyscripter 中那样将鼠标悬停在变量上并弹出变量来源的描述。