如何修改robotFramework-ride 背景色

更新: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\robotide\editor\texteditor.py

C:\Users\park\AppData\Roaming\RobotFramework\ride\settings.cfg


我发现最关键的地方,还是在 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...

#  Copyright 2008-2012 Nokia Siemens Networks Oyj
#
#  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/licenses/LICENSE-2.0
#
#  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, text=None):
        self._editor = RobotDataEditor(self)
        self.Sizer.add_expanding(self. _editor)
        self.Sizer.Layout()
        if text is not None:
            self._editor.set_text(text)
        self._editor.Bind(wx.EVT_KEY_ UP, self.OnEditorKey)
        self._editor.Bind(wx.EVT_KILL_ FOCUS, self.LeaveFocus)
        self._editor.Bind(wx.EVT_SET_ FOCUS, self.GetFocus)

    def LeaveFocus(self, event):
        self._editor.SetCaretPeriod(0)
        self._editor.SetCaretForeground(wx.WHITE)
        self.save()

    def GetFocus(self, event):
        self._editor.SetCaretPeriod(500)
        self._editor.SetCaretForeground(wx.WHITE)
        event.Skip()


    def _revert(self):
        self.reset()
        self._editor.set_text(self._ data.content)

    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. 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, wx.BLACK)


    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( FromFilePopulator):

    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. RobotFrameworkLexer()
            self._set_styles()
        else:
            self.editor.GetParent(). create_syntax_colorization_ help()

    def _set_styles(self):
        color_settings = self.settings.get_without_default('Text Edit Colors')
        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_NAME: {
                '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( index, self._get_style_string(** styles[token]))

    def _get_word_and_length(self, current_position):
        word = self.editor.GetTextRange( current_position, self.editor.WordEndPosition( current_position, False))
        return word, len(word)

    def _get_style_string(self, back='#000000', face='Courier', fore='#000000', bold='', italic='',underline=''):
        settings = locals()
        settings.update(size=self. font_size)
        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_ unprocessed(self.editor. GetText()):
            self.editor.StartStyling( position+shift, 31)
            self.editor.SetStyling(len( value.encode('utf-8')), self.tokens[token])
            shift += len(value.encode('utf-8'))- len(value)

------------------------------ ------------------------------ ------------------------------ ----------
C:\Users\park\AppData\Roaming\RobotFramework\ride\settings.cfg
< -------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'

....
...
..

参考:

https://groups.google.com/forum/#!topic/robotframework-users/VEAVyhpu-iU

C:\Python27\Lib\site-packages\ robotide\editor\texteditor.py
### 回答1: robotframework-ride是一个基于Python编写的自动化测试工具,它可以帮助测试人员快速创建和运行自动化测试用例。安装robotframework-ride需要先安装Python和pip,然后使用pip命令安装robotframework-ride。具体步骤如下: 1. 安装Python:从Python官网下载并安装Python,建议安装最新版本的Python。 2. 安装pip:pip是Python的包管理工具,可以使用pip安装和管理Python包。在安装Python时,pip已经被自动安装了。可以通过运行pip --version命令来检查pip是否已经安装。 3. 安装robotframework-ride:使用pip命令安装robotframework-ride,可以使用以下命令: pip install robotframework-ride 4. 启动robotframework-ride:安装完成后,可以通过运行ride.py文件启动robotframework-ride。可以在命令行中输入以下命令: python -m robotide.__init__ 或者直接双击ride.py文件启动。 安装完成后,就可以使用robotframework-ride创建和运行自动化测试用例了。 ### 回答2: Robot Framework是一个通用的自动化测试框架,可以用来测试各种应用程序和Web应用程序。RIDE(Robot Framework Integrated Development Environment)是一个基于Python的集成开发环境,使用RIDE工具可以大大减轻测试用例的编写和管理负担。RIDE支持使用Python或Robot Framework的打印输出,实时编辑测试数据和测试套件,以便于开发人员和测试人员开发和维护测试用例。 安装RIDE有几种不同的方法,可以选择最适合你的环境的方法。以下是安装RIDE的步骤: 1. 安装Python:在安装RIDE之前,需要在计算机上安装Python 2.7版本或Python 3.X版本,根据需要选择版本。 2. 安装wxPython:RIDE使用wxPython提供GUI,因此需要安装wxPython库。可以在官网下载:https://www.wxpython.org/pages/downloads/。根据需要选择相应的版本,下载完之后直接运行安装程序进行安装即可。 3. 安装Robot Framework:在安装RIDE之前,需要安装Robot Framework。可以使用pip命令进行安装。在命令提示符中输入以下命令即可:pip install robotframework 4. 安装RIDE:在安装完上述软件之后,就可以开始安装RIDE了。可以从官方网站下载RIDE,下载地址为:http://code.google.com/p/robotframework-ride/downloads/list。在下载完成之后,解压缩文件并运行RIDE.bat文件即可启动RIDE。这里需要注意的是,必须使用管理员身份运行RIDE.bat。 5. 配置RIDE:在RIDE启动后,需要进行一些配置。首先,需要配置Robot Framework的路径。在菜单中选择“Tools” > “Preferences”,然后在“Plugins”选项卡中选择“RobotFramework”,在“Executable”字段中输入Robot Framework安装目录的完整路径。然后,可以选择“Editor”选项卡来配置编辑器首选项。此外,还可以在其他选项卡中配置更多选项,如自动保存机制等。 以上就是Robot Framework- RIDE安装的步骤,根据这些步骤进行安装,可以使您简单高效地进行测试用例的管理和编写,提交测试工作效率。 ### 回答3: Robot Framework是一种通用的自动化测试框架,它支持各种不同类型的测试,包括Web、移动、API等。Robot Framework的优点在于它可以轻松地创建可读性强、易于维护的测试用例。 同时,Robot Framework也提供了许多工具来简化测试执行,其中一个常用的工具就是RIDE。RIDE是Robot Framework的官方开发IDE,它提供了一个用户友好的界面,使得创建、编辑和运行测试用例变得更加容易。 下面我们来看一下如何安装RIDE: 1. 安装Python 首先需要安装Python 2.7.x 版本的解释器,请从Python官方网站 https://www.python.org/downloads/ 下载Python 2.7.x版本的32位或64位安装程序,根据自己的操作系统和PC硬件配置选择对应的版本。 2. 安装wxPython RIDE使用wxPython实现了它的用户界面。你需要安装wxPython来运行RIDE。可以使用Python的包管理器pip来安装wxPython,如下: 打开控制台并执行以下命令: pip install wxPython 3. 安装Robot Framework和RIDE 接下来我们需要安装Robot Framework和RIDE。同样可以使用pip命令管理器完成安装。在控制台输入以下命令: pip install robotframework pip install robotframework-ride 4. 运行RIDE 安装完成后,在文件资源管理器中定位到安装目录,双击‘ride.py’文件运行RIDE。如果RIDE成功启动,你将会看到RIDE的主界面。 5. 创建测试用例 点击‘Create a new test case file’按钮,输入文件名并以“.txt”为文件扩展名。文件将保存在你选择的路径下。使用文本编辑器的语法,你可以轻松地创建测试用例。 以上就是Robot Framework-RIDE的安装过程,通过这篇教程,你应该可以轻松地完成一个新的测试项目并开始优化你的测试流程。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值