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.

43 lines
1.3 KiB

  1. '''
  2. Main runner entry point for Gooey.
  3. '''
  4. import wx
  5. # wx.html and wx.xml imports required here to make packaging with
  6. # pyinstaller on OSX possible without manually specifying `hidden_imports`
  7. # in the build.spec
  8. import wx.html
  9. import wx.xml
  10. import wx.richtext # Need to be imported before the wx.App object is created.
  11. import wx.lib.inspection
  12. from gooey.gui.lang import i18n
  13. from gooey.gui import image_repository
  14. from gooey.gui.containers.application import GooeyApplication
  15. from gooey.util.functional import merge
  16. def run(build_spec):
  17. app, _ = build_app(build_spec)
  18. app.MainLoop()
  19. def build_app(build_spec):
  20. app = wx.App(False)
  21. return _build_app(build_spec, app)
  22. def _build_app(build_spec, app):
  23. """
  24. Note: this method is broken out with app as
  25. an argument to facilitate testing.
  26. """
  27. # use actual program name instead of script file name in macOS menu
  28. app.SetAppDisplayName(build_spec['program_name'])
  29. i18n.load(build_spec['language_dir'], build_spec['language'], build_spec['encoding'])
  30. imagesPaths = image_repository.loadImages(build_spec['image_dir'])
  31. gapp = GooeyApplication(merge(build_spec, imagesPaths))
  32. # wx.lib.inspection.InspectionTool().Show()
  33. gapp.Show()
  34. return (app, gapp)