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.

109 lines
2.8 KiB

  1. '''
  2. Created on Jan 19, 2014
  3. New plan:
  4. fuck the multi-component thing.
  5. Bind and unbind the buttons on the panels.
  6. @author: Chris
  7. '''
  8. import os
  9. import wx
  10. import sys
  11. import header
  12. from gooey import i18n
  13. from gooey.gui import footer
  14. from gooey import image_repository
  15. from gooey.gui.controller import Controller
  16. from gooey.gui.runtime_display_panel import RuntimeDisplay
  17. import styling
  18. class BaseWindow(wx.Frame):
  19. def __init__(self, BodyPanel, client_app, params):
  20. wx.Frame.__init__(self, parent=None, id=-1)
  21. self._params = params
  22. self._client_app = client_app
  23. self._controller = None
  24. # Components
  25. self.icon = None
  26. self.head_panel = None
  27. self.config_panel = None
  28. self.runtime_display = None
  29. self.foot_panel = None
  30. self.panels = None
  31. self._init_properties()
  32. self._init_components(BodyPanel)
  33. self._do_layout()
  34. self._init_controller()
  35. self.registerControllers()
  36. def _init_properties(self):
  37. if not self._params['program_name']:
  38. title = os.path.basename(sys.argv[0].replace('.py', ''))
  39. else:
  40. title = self._params['program_name']
  41. self.SetTitle(title)
  42. self.SetSize((610, 530))
  43. self.SetMinSize((400, 300))
  44. self.icon = wx.Icon(image_repository.icon, wx.BITMAP_TYPE_ICO)
  45. self.SetIcon(self.icon)
  46. def _init_components(self, BodyPanel):
  47. # init gui
  48. self.head_panel = header.FrameHeader(
  49. heading=i18n.translate("settings_title"),
  50. subheading=self._client_app.description,
  51. parent=self)
  52. self.config_panel = BodyPanel(self)
  53. self.runtime_display = RuntimeDisplay(self)
  54. self.foot_panel = footer.Footer(self, self._controller)
  55. self.panels = [self.head_panel, self.config_panel, self.foot_panel]
  56. def _do_layout(self):
  57. sizer = wx.BoxSizer(wx.VERTICAL)
  58. sizer.Add(self.head_panel, 0, wx.EXPAND)
  59. sizer.Add(styling.HorizontalRule(self), 0, wx.EXPAND)
  60. sizer.Add(self.config_panel, 1, wx.EXPAND)
  61. self.runtime_display.Hide()
  62. sizer.Add(self.runtime_display, 1, wx.EXPAND)
  63. sizer.Add(styling.HorizontalRule(self), 0, wx.EXPAND)
  64. sizer.Add(self.foot_panel, 0, wx.EXPAND)
  65. self.SetSizer(sizer)
  66. def _init_controller(self):
  67. self._controller = Controller(
  68. base_frame=self,
  69. client_app=self._client_app)
  70. def registerControllers(self):
  71. for panel in self.panels:
  72. panel.RegisterController(self._controller)
  73. def GetOptions(self):
  74. return self.config_panel.GetOptions()
  75. def NextPage(self):
  76. self.head_panel.NextPage()
  77. self.foot_panel.NextPage()
  78. self.config_panel.Hide()
  79. self.runtime_display.Show()
  80. self.Layout()
  81. # def AttachPayload(self, payload):
  82. # self._payload = payload
  83. def ManualStart(self):
  84. self._controller.ManualStart()
  85. if __name__ == '__main__':
  86. pass