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.

98 lines
2.8 KiB

  1. '''
  2. Created on Dec 23, 2013
  3. @author: Chris
  4. '''
  5. import itertools
  6. import wx
  7. from gooey import i18n
  8. from gooey.gui import imageutil
  9. from gooey import image_repository
  10. import styling
  11. PAD_SIZE = 10
  12. class FrameHeader(wx.Panel):
  13. def __init__(self, heading, subheading, **kwargs):
  14. wx.Panel.__init__(self, **kwargs)
  15. self._controller = None
  16. self._header = None
  17. self._subheader = None
  18. self._settings_img = None
  19. self._running_img = None
  20. self._check_mark = None
  21. self._init_properties()
  22. self._init_components(heading, subheading)
  23. self._init_pages()
  24. self._do_layout()
  25. def _init_properties(self):
  26. self.SetBackgroundColour('#ffffff')
  27. self.SetSize((30, 90))
  28. self.SetMinSize((120, 80))
  29. def _init_components(self, heading, subheading):
  30. self._header = styling.H1(self, heading)
  31. self._subheader = wx.StaticText(self, label=subheading)
  32. self._settings_img = self._load_image(image_repository.settings2, height=79)
  33. self._running_img = self._load_image(image_repository.computer3, 79)
  34. self._check_mark = self._load_image(image_repository.alessandro_rei_checkmark, height=75)
  35. def _do_layout(self):
  36. vsizer = wx.BoxSizer(wx.VERTICAL)
  37. sizer = wx.BoxSizer(wx.HORIZONTAL)
  38. headings_sizer = self.build_heading_sizer()
  39. sizer.Add(headings_sizer, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_HORIZONTAL | wx.EXPAND | wx.LEFT, PAD_SIZE)
  40. sizer.Add(self._settings_img, 0, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, PAD_SIZE)
  41. sizer.Add(self._running_img, 0, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, PAD_SIZE)
  42. sizer.Add(self._check_mark, 0, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, PAD_SIZE)
  43. self._running_img.Hide()
  44. self._check_mark.Hide()
  45. vsizer.Add(sizer, 1, wx.EXPAND)
  46. self.SetSizer(vsizer)
  47. def _load_image(self, img_path, height=70):
  48. return imageutil.resize_bitmap(self, imageutil._load_image(img_path), height)
  49. def build_heading_sizer(self):
  50. sizer = wx.BoxSizer(wx.VERTICAL)
  51. sizer.AddStretchSpacer(1)
  52. sizer.Add(self._header, 0)
  53. sizer.Add(self._subheader, 0)
  54. sizer.AddStretchSpacer(1)
  55. return sizer
  56. def RegisterController(self, controller):
  57. if self._controller is None:
  58. self._controller = controller
  59. def _init_pages(self):
  60. def PageOne():
  61. self._header.SetLabel(i18n.translate("running_title"))
  62. self._subheader.SetLabel(i18n.translate('running_msg'))
  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. next(self._pages)()