更新:2017年8月8日16:35:59
修改 text edit 的背景色
打开C:\Python27\Lib\site-packages\robotide\editor\texteditor.py
class RobotDataEditor(stc.StyledTextCtrl): def __init__(self, parent): stc.StyledTextCtrl.__init__(self, parent) self.SetMarginType(0, stc.STC_MARGIN_NUMBER) self.SetMarginWidth(0, self.TextWidth(stc.STC_STYLE_LINENUMBER,'1234')) self.SetReadOnly(True) self.SetLexer(stc.STC_LEX_CONTAINER) self.Bind(stc.EVT_STC_STYLENEEDED, self.OnStyle) self.stylizer = RobotStylizer(self, parent._parent._app.settings) self.StyleSetBackground(wx.stc.STC_STYLE_DEFAULT, '#C7EDCC')#change ride backgrround
添加最后一行即为护眼色
self.StyleSetBackground(wx.stc.STC_STYLE_DEFAULT, '#C7EDCC')#change ride backgrround
如果想修改grid editor 背景色,直接打开Tools-->preferences,选择Grid Editor,将白色的背景色,全部修改成自定义的颜色
护眼色
色调:85;饱和度:123;亮度:205,
'---------------------------------------------------下面是原答案----------------------------------------------------------------
修改两个地方的文件如下图所示.
C:\Python27\Lib\site-packages\
C:\Users\park\AppData\Roaming\
我发现最关键的地方,还是在
texteditor.py,修改单引号的颜色代码即可.但是文件夹树那边没有办法修改颜色,很气,等待解决吧.
self.StyleSetBackground(wx.stc.STC_STYLE_DEFAULT, '#C7EDCC')
具体步骤如下所示:
C:\Python27\Lib\site-packages\ robotide\editor\texteditor.py
<-------This path may different each users...
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from time import time
from robotide.context.platform import IS_WINDOWS, IS_MAC
import wx
from wx import stc
from StringIO import StringIO
import string
from robot.parsing.model import TestDataDirectory
from robot.parsing.populators import FromFilePopulator
from robot.parsing.txtreader import TxtReader
from robotide.controller.commands import SetDataFile
from robotide.controller.dataloader import TestDataDirectoryWithExcludes
from robotide.publish.messages import RideMessage
from robotide.widgets import VerticalSizer, HorizontalSizer, ButtonWithHandler
from robotide.pluginapi import (Plugin, RideSaving, TreeAwarePluginMixin,
RideTreeSelection, RideNotebookTabChanging, RideDataChanged,
RideOpenSuite, RideDataChangedToDirty)
from robotide.widgets.text import TextField
from robotide.widgets.label import Label
....
...
..
.
def _create_editor_text_control(
self._editor = RobotDataEditor(self)
self.Sizer.add_expanding(self.
self.Sizer.Layout()
if text is not None:
self._editor.set_text(text)
self._editor.Bind(wx.EVT_KEY_
self._editor.Bind(wx.EVT_KILL_
self._editor.Bind(wx.EVT_SET_
def LeaveFocus(self, event):
self._editor.SetCaretPeriod(0)
self._editor.
self.save()
def GetFocus(self, event):
self._editor.SetCaretPeriod(
self._editor.
event.Skip()
def _revert(self):
self.reset()
self._editor.set_text(self._
def OnEditorKey(self, event):
if not self.dirty and self._editor.GetModify():
self._mark_file_dirty()
event.Skip()
def _mark_file_dirty(self):
if self._data:
self._dirty = True
self._data.mark_data_dirty()
class RobotDataEditor(stc.
def __init__(self, parent):
stc.StyledTextCtrl.__init__(
self.SetMarginType(0, stc.STC_MARGIN_NUMBER)
self.SetMarginWidth(0, self.TextWidth(stc.STC_STYLE_
self.SetReadOnly(True)
self.SetLexer(stc.STC_LEX_
self.Bind(stc.EVT_STC_
self.stylizer = RobotStylizer(self, parent._parent._app.settings)
self.StyleSetBackground(wx.
def set_text(self, text):
self.SetReadOnly(False)
self.SetText(text)
self.stylizer.stylize()
self.EmptyUndoBuffer()
@property
def utf8_text(self):
return self.GetText().encode('UTF-8')
def OnStyle(self, event):
self.stylizer.stylize()
class FromStringIOPopulator(
def populate(self, content):
TxtReader().read(content, self)
class RobotStylizer(object):
def __init__(self, editor, settings):
self.editor = editor
self.lexer = None
self.settings = settings
self.font_size = settings.get('text edit font size', 8)
if robotframeworklexer:
self.lexer = robotframeworklexer.
self._set_styles()
else:
self.editor.GetParent().
def _set_styles(self):
color_settings = self.settings.get_without_
styles = {
robotframeworklexer.ARGUMENT: {
'fore': color_settings['argument']
},
robotframeworklexer.COMMENT: {
'fore': color_settings['comment'],
'bold': 'false',
'italic': 'true'
},
robotframeworklexer.ERROR: {
'fore': color_settings['error']
},
robotframeworklexer.GHERKIN: {
'fore': color_settings['gherkin']
},
robotframeworklexer.HEADING: {
'fore': color_settings['heading'],
'bold': 'true'
},
robotframeworklexer.IMPORT: {
'fore': color_settings['import']
},
robotframeworklexer.KEYWORD: {
'fore': color_settings['keyword'],
'bold': 'true'
},
robotframeworklexer.SEPARATOR: {
'fore': color_settings['separator']
},
robotframeworklexer.SETTING: {
'fore': color_settings['setting'],
'bold': 'true'
},
robotframeworklexer.SYNTAX: {
'fore': color_settings['syntax']
},
robotframeworklexer.TC_KW_
'fore': color_settings['tc_kw_name'],
'bold': 'true'
},
robotframeworklexer.VARIABLE: {
'fore': color_settings['variable'],
'bold': 'true'
}
}
self.tokens = {}
for index, token in enumerate(styles):
self.tokens[token] = index
self.editor.StyleSetSpec(
def _get_word_and_length(self, current_position):
word = self.editor.GetTextRange(
return word, len(word)
def _get_style_string(self, back='#000000', face='Courier', fore='#000000', bold='', italic='',underline=''):
settings = locals()
settings.update(size=self.
return ','.join('%s:%s' % (name, value) for name, value in settings.items() if value)
def stylize(self):
if not self.lexer:
return
self.editor.ConvertEOLs(2)
shift = 0
for position, token, value in self.lexer.get_tokens_
self.editor.StartStyling(
self.editor.SetStyling(len(
shift += len(value.encode('utf-8'))-
------------------------------
------------------------------
------------------------------
----------
C:\Users\park\AppData\Roaming\ RobotFramework\ride\settings. cfg
< -------This path may different each users...
< -------This path may different each users...
..
...
....
[Text Edit Colors]
argument = '#E0E0E0'
comment = '#008080'
error = 'black'
gherkin = 'black'
heading = '#FF0000'
import = '#FF00FF'
keyword = '#00BFFF'
separator = 'black'
setting = '#FFFF00'
syntax = '#8000FF'
tc_kw_name = '#00FF00'
variable = '#FF8000'
[Grid Colors]
text user keyword = 'blue'
text library keyword = '#0080C0'
text variable = 'forest green'
text unknown variable = 'purple'
text commented = 'firebrick'
text string = 'black'
text empty = 'black'
background assign = '#FFFFFF'
background keyword = '#FFFFFF'
background mandatory = '#FFFFFF'
background optional = '#F5F5F5'
background must be empty = '#C0C0C0'
background unknown = '#FFFFFF'
background error = '#FF9385'
background highlight = '#FFFF77'
[Text Edit Colors]
argument = '#E0E0E0'
comment = '#008080'
error = 'black'
gherkin = 'black'
heading = '#FF0000'
import = '#FF00FF'
keyword = '#00BFFF'
separator = 'black'
setting = '#FFFF00'
syntax = '#8000FF'
tc_kw_name = '#00FF00'
variable = '#FF8000'
[Grid Colors]
text user keyword = 'blue'
text library keyword = '#0080C0'
text variable = 'forest green'
text unknown variable = 'purple'
text commented = 'firebrick'
text string = 'black'
text empty = 'black'
background assign = '#FFFFFF'
background keyword = '#FFFFFF'
background mandatory = '#FFFFFF'
background optional = '#F5F5F5'
background must be empty = '#C0C0C0'
background unknown = '#FFFFFF'
background error = '#FF9385'
background highlight = '#FFFF77'
....
...
..
参考:
https://groups.google.com/forum/#!topic/robotframework-users/VEAVyhpu-iU
C:\Python27\Lib\site-packages\
robotide\editor\texteditor.py