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.

46 lines
1.4 KiB

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