Robot Framework Integrated Development Environment (RIDE)
images.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 os
17 
18 import wx
19 
20 
21 class ImageList(wx.ImageList):
22 
23  def __init__(self, img_width, img_height):
24  wx.ImageList.__init__(self, img_width, img_height)
25 
26  def add(self, image):
27  self.Add(image)
28 
29 
30 class ImageProvider():
31 
34  _BASE = os.path.dirname(__file__)
35 
36  def __init__(self, size=(16, 16)):
37  self._size_size = size
38  self.TESTCASEIMGTESTCASEIMG = self._load_image_load_image('robot.png')
39  self.KEYWORDIMGKEYWORDIMG = self._load_image_load_image('process.png')
40  self.DATADIRIMGDATADIRIMG = self._img_from_art_provider_img_from_art_provider(wx.ART_FOLDER)
41  self.DATAFILEIMGDATAFILEIMG = self._img_from_art_provider_img_from_art_provider(wx.ART_NORMAL_FILE)
42  self.PROGICONSPROGICONS = self._load_prog_icons_load_prog_icons()
43  self.REPORTIMGREPORTIMG = self._load_image_load_image('report.png')
44  self.REFRESH_ALLREFRESH_ALL = self._load_image_load_image('database_refresh.png')
45  self.KW_SEARCH_ICONKW_SEARCH_ICON = self._load_image_load_image('kw_search_button.png')
46  self.TEST_SEARCH_ICONTEST_SEARCH_ICON = self._load_image_load_image('test_search_button.png')
47  self.TOOLBAR_PLAYTOOLBAR_PLAY = self._load_image_load_image('control_play.png')
48  self.TOOLBAR_STOPTOOLBAR_STOP = self._load_image_load_image('control_stop.png')
49  self.TOOLBAR_PAUSETOOLBAR_PAUSE = self._load_image_load_image('control_pause.png')
50  self.TOOLBAR_CONTINUETOOLBAR_CONTINUE = self._load_image_load_image('control_play.png')
51  self.TOOLBAR_NEXTTOOLBAR_NEXT = self._load_image_load_image('control_fastforward.png')
52  self.SWITCH_FIELDS_ICONSWITCH_FIELDS_ICON = self._load_image_load_image('switch.png')
53  self.RIDE_ICONRIDE_ICON = self._load_image_load_image('robot.ico')
54  self._build_icons_build_icons()
55 
56  def _build_icons(self):
57  self._icons_icons = {}
58  for name in dir(self):
59  value = getattr(self, name)
60  if isinstance(value, wx.Bitmap):
61  self._icons_icons[name] = getattr(self, name)
62 
63  def get_image_by_name(self, name):
64  return self._icons_icons.get(name, None)
65 
66  def _load_image(self, name):
67  path = self._get_img_path_get_img_path(name)
68  noLog = wx.LogNull()
69  # Suppress warnings generated by recent libpng versions.
70  # The png files themselves are most likely ok.
71  img = wx.Image(path, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
72  del noLog
73  return img
74 
75  def _get_img_path(self, name):
76  return os.path.join(self._BASE_BASE, name)
77 
78  def _img_from_art_provider(self, source):
79  return wx.ArtProvider.GetBitmap(source, wx.ART_OTHER, self._size_size)
80 
81  def _load_prog_icons(self):
82  icons = wx.IconBundle()
83  icons.AddIcon(self._get_img_path_get_img_path('robot.ico'), wx.BITMAP_TYPE_ANY)
84  return icons
def __init__(self, img_width, img_height)
Definition: images.py:23
def get_image_by_name(self, name)
Definition: images.py:63
def _img_from_art_provider(self, source)
Definition: images.py:78
def __init__(self, size=(16, 16))
Definition: images.py:36