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.

103 lines
3.0 KiB

  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 import styling
  8. from gooey.gui.lang import i18n
  9. PAD_SIZE = 10
  10. class FrameHeader(wx.Panel):
  11. def __init__(self, heading, subheading, **kwargs):
  12. wx.Panel.__init__(self, **kwargs)
  13. self.SetDoubleBuffered(True)
  14. self._controller = None
  15. self._header = None
  16. self._subheader = None
  17. self._settings_img = None
  18. self._running_img = None
  19. self._check_mark = None
  20. self._init_properties()
  21. self._init_components(heading, subheading)
  22. self._init_pages()
  23. self._do_layout()
  24. def _init_properties(self):
  25. self.SetBackgroundColour('#ffffff')
  26. self.SetSize((30, 90))
  27. self.SetMinSize((120, 80))
  28. def _init_components(self, heading, subheading):
  29. self._header = styling.H1(self, heading)
  30. self._subheader = wx.StaticText(self, label=subheading)
  31. self._settings_img = self._load_image(image_repository.settings2, height=79)
  32. self._running_img = self._load_image(image_repository.computer3, 79)
  33. self._check_mark = self._load_image(image_repository.alessandro_rei_checkmark, height=75)
  34. def _do_layout(self):
  35. vsizer = wx.BoxSizer(wx.VERTICAL)
  36. sizer = wx.BoxSizer(wx.HORIZONTAL)
  37. headings_sizer = self.build_heading_sizer()
  38. sizer.Add(headings_sizer, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_HORIZONTAL | wx.EXPAND | wx.LEFT, PAD_SIZE)
  39. sizer.Add(self._settings_img, 0, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, PAD_SIZE)
  40. sizer.Add(self._running_img, 0, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, PAD_SIZE)
  41. sizer.Add(self._check_mark, 0, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, PAD_SIZE)
  42. self._running_img.Hide()
  43. self._check_mark.Hide()
  44. vsizer.Add(sizer, 1, wx.EXPAND)
  45. self.SetSizer(vsizer)
  46. def _load_image(self, img_path, height=70):
  47. return imageutil.resize_bitmap(self, imageutil._load_image(img_path), height)
  48. def build_heading_sizer(self):
  49. sizer = wx.BoxSizer(wx.VERTICAL)
  50. sizer.AddStretchSpacer(1)
  51. sizer.Add(self._header, 0)
  52. sizer.Add(self._subheader, 0)
  53. sizer.AddStretchSpacer(1)
  54. return sizer
  55. def RegisterController(self, controller):
  56. if self._controller is None:
  57. self._controller = controller
  58. def _init_pages(self):
  59. def PageOne():
  60. self._header.SetLabel(i18n.translate("running_title"))
  61. self._subheader.SetLabel(i18n.translate('running_msg'))
  62. self._check_mark.Hide()
  63. self._settings_img.Hide()
  64. self._running_img.Show()
  65. self.Layout()
  66. def PageTwo():
  67. self._header.SetLabel(i18n.translate('finished_title'))
  68. self._subheader.SetLabel(i18n.translate('finished_msg'))
  69. self._running_img.Hide()
  70. self._check_mark.Show()
  71. self.Layout()
  72. self._pages = iter([PageOne, PageTwo])
  73. def NextPage(self):
  74. try:
  75. next(self._pages)()
  76. except:
  77. self._init_pages()
  78. next(self._pages)()