You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.5 KiB

8 years ago
  1. '''
  2. Created on Dec 23, 2013
  3. @author: Chris
  4. '''
  5. import wx
  6. from gooey.gui import imageutil, image_repository
  7. from gooey.gui.util import wx_util
  8. PAD_SIZE = 10
  9. class FrameHeader(wx.Panel):
  10. def __init__(self, parent=None, **kwargs):
  11. wx.Panel.__init__(self, parent, **kwargs)
  12. self.SetDoubleBuffered(True)
  13. self._header = None
  14. self._subheader = None
  15. self.settings_img = None
  16. self.running_img = None
  17. self.check_mark = None
  18. self.error_symbol = None
  19. self._init_properties()
  20. self._init_components()
  21. self._do_layout()
  22. @property
  23. def title(self):
  24. return self._header.GetLabel()
  25. @title.setter
  26. def title(self, text):
  27. self._header.SetLabel(text)
  28. @property
  29. def subtitle(self):
  30. return self._subheader.GetLabel()
  31. @subtitle.setter
  32. def subtitle(self, text):
  33. self._subheader.SetLabel(text)
  34. def _init_properties(self):
  35. self.SetBackgroundColour('#ffffff')
  36. self.SetSize((30, 90))
  37. self.SetMinSize((120, 80))
  38. def _init_components(self):
  39. self._header = wx_util.h1(self, '')
  40. self._subheader = wx.StaticText(self, label='')
  41. self.settings_img = self._load_image(image_repository.config_icon, height=79)
  42. self.running_img = self._load_image(image_repository.running_icon, 79)
  43. self.check_mark = self._load_image(image_repository.success_icon, height=75)
  44. self.error_symbol = self._load_image(image_repository.error_icon, height=75)
  45. def _do_layout(self):
  46. vsizer = wx.BoxSizer(wx.VERTICAL)
  47. sizer = wx.BoxSizer(wx.HORIZONTAL)
  48. headings_sizer = self.build_heading_sizer()
  49. sizer.Add(headings_sizer, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_HORIZONTAL | wx.EXPAND | wx.LEFT, PAD_SIZE)
  50. sizer.Add(self.settings_img, 0, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, PAD_SIZE)
  51. sizer.Add(self.running_img, 0, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, PAD_SIZE)
  52. sizer.Add(self.check_mark, 0, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, PAD_SIZE)
  53. sizer.Add(self.error_symbol, 0, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, PAD_SIZE)
  54. self.running_img.Hide()
  55. self.check_mark.Hide()
  56. self.error_symbol.Hide()
  57. vsizer.Add(sizer, 1, wx.EXPAND)
  58. self.SetSizer(vsizer)
  59. def _load_image(self, img_path, height=70):
  60. return imageutil.resize_bitmap(self, imageutil._load_image(img_path), height)
  61. def build_heading_sizer(self):
  62. sizer = wx.BoxSizer(wx.VERTICAL)
  63. sizer.AddStretchSpacer(1)
  64. sizer.Add(self._header, 0)
  65. sizer.Add(self._subheader, 0)
  66. sizer.AddStretchSpacer(1)
  67. return sizer