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.

45 lines
1.2 KiB

  1. from concurrent.futures import ThreadPoolExecutor
  2. from threading import Thread
  3. from typing import Callable, Dict, Any
  4. from gooey.gui import seeder
  5. from gooey.gui import state as s
  6. from gooey.gui.state import FullGooeyState
  7. from gooey.python_bindings.types import Try, PublicGooeyState
  8. def communicateFormValidation(state: FullGooeyState, callback: Callable[[Try[Dict[str, str]]], None]) -> None:
  9. communicateAsync(s.buildFormValidationCmd(state), state, callback)
  10. def communicateSuccessState(state: FullGooeyState, callback: Callable[[Try[PublicGooeyState]], None]) -> None:
  11. communicateAsync(s.buildOnSuccessCmd(state), state, callback)
  12. def communicateErrorState(state: FullGooeyState, callback: Callable[[Try[PublicGooeyState]], None]) -> None:
  13. communicateAsync(s.buildOnErrorCmd(state), state, callback)
  14. def fetchFieldValidation():
  15. pass
  16. def fetchFieldAction():
  17. pass
  18. def fetchFormAction():
  19. pass
  20. def communicateAsync(cmd: str, state: FullGooeyState, callback: Callable[[Any], None]):
  21. """
  22. Callable MUST be wrapped in wx.CallAfter if its going to
  23. modify the UI.
  24. """
  25. def work():
  26. result = seeder.communicate(cmd, state['encoding'])
  27. callback(result)
  28. thread = Thread(target=work)
  29. thread.start()