Robot Framework Integrated Development Environment (RIDE)
htmlwnd.py
Go to the documentation of this file.
1 # Copyright 2008-2015 Nokia Networks
2 # Copyright 2016- Robot Framework Foundation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 import webbrowser
17 
18 import wx
19 from wx import html, Colour
20 
21 from ..preferences.settings import RideSettings
22 
23 #TODO: Make this colour configurable
24 # HTML_BACKGROUND = (240, 242, 80) # (200, 222, 40)
25 
28 _settings = RideSettings()
29 general_settings = _settings['General']
30 HTML_BACKGROUND = general_settings['background help']
31 
32 
33 class HtmlWindow(html.HtmlWindow):
34 
35  def __init__(self, parent, size=wx.DefaultSize, text=None):
36  html.HtmlWindow.__init__(self, parent, size=size)
37  self.SetBorders(2)
38  self.SetStandardFonts(size=9)
39  self.SetBackgroundColour(Colour(200, 222, 40))
40  self.SetOwnBackgroundColour(Colour(200, 222, 40))
41  self.SetOwnForegroundColour(Colour(7, 0, 70))
42  if text:
43  self.set_contentset_content(text)
44  self.SetHTMLBackgroundColour(Colour(general_settings['background help']))
45  self.SetForegroundColour(Colour(general_settings['foreground help']))
46  self.fontfont = self.GetFont()
47  self.fontfont.SetFaceName(general_settings['font face'])
48  self.fontfont.SetPointSize(general_settings['font size'])
49  self.SetFont(self.fontfont)
50  self.Refresh(True)
51  self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDownOnKeyDown)
52 
53  def set_content(self, content):
54  color = ''.join(hex(item)[2:] for item in general_settings['background help'])
55 
58  _content = '<body bgcolor=#%s>%s</body>' % (color, content)
59  self.SetPage(_content)
60 
61  def OnKeyDown(self, event):
62  if self._is_copy_is_copy(event):
63  self._add_selection_to_clipboard_add_selection_to_clipboard()
64  self.Parent.OnKey(event)
65  event.Skip()
66 
67  def _is_copy(self, event):
68  return event.GetKeyCode() == ord('C') and event.CmdDown()
69 
71  wx.TheClipboard.Open()
72  wx.TheClipboard.SetData(wx.TextDataObject(self.SelectionToText()))
73  wx.TheClipboard.Close()
74 
75  def OnLinkClicked(self, link):
76  webbrowser.open(link.Href)
77 
78  def close(self):
79  self.Show(False)
80 
81  def clear(self):
82  self.SetPage('')
83 
def __init__(self, parent, size=wx.DefaultSize, text=None)
Definition: htmlwnd.py:35
def set_content(self, content)
Definition: htmlwnd.py:53