Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
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.

wxsupport.py 1.3KB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Copyright (c) Twisted Matrix Laboratories.
  2. # See LICENSE for details.
  3. #
  4. """Old method of wxPython support for Twisted.
  5. twisted.internet.wxreactor is probably a better choice.
  6. To use::
  7. | # given a wxApp instance called myWxAppInstance:
  8. | from twisted.internet import wxsupport
  9. | wxsupport.install(myWxAppInstance)
  10. Use Twisted's APIs for running and stopping the event loop, don't use
  11. wxPython's methods.
  12. On Windows the Twisted event loop might block when dialogs are open
  13. or menus are selected.
  14. Maintainer: Itamar Shtull-Trauring
  15. """
  16. import warnings
  17. warnings.warn("wxsupport is not fully functional on Windows, wxreactor is better.")
  18. from twisted.internet import reactor
  19. class wxRunner:
  20. """Make sure GUI events are handled."""
  21. def __init__(self, app):
  22. self.app = app
  23. def run(self):
  24. """
  25. Execute pending WX events followed by WX idle events and
  26. reschedule.
  27. """
  28. # run wx events
  29. while self.app.Pending():
  30. self.app.Dispatch()
  31. # run wx idle events
  32. self.app.ProcessIdle()
  33. reactor.callLater(0.02, self.run)
  34. def install(app):
  35. """Install the wxPython support, given a wxApp instance"""
  36. runner = wxRunner(app)
  37. reactor.callLater(0.02, runner.run)
  38. __all__ = ["install"]