test.py 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # coding:utf-8
  2. #!/usr/bin/python
  3. #
  4. # Copyright (c) Contributors to the Open 3D Engine Project.
  5. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  6. #
  7. # SPDX-License-Identifier: Apache-2.0 OR MIT
  8. #
  9. #
  10. """This is a module to test script extensions for WingIDE
  11. reference: https://wingware.com/doc/scripting/example
  12. note: there are important instructions in that doc for
  13. setting up your project files with wingapi auto-complete, etc.
  14. We added C:\Program Files (x86)\Wing Pro 7.1\src to the
  15. PYTHONPATH via env.bat and dynaconf config instead so it is
  16. part of the inhereted environment."""
  17. import sys
  18. import logging as _logging
  19. import wingapi
  20. # -------------------------------------------------------------------------
  21. _MODULENAME = 'azpy.dev.ide.wing.test'
  22. _LOGGER = _logging.getLogger(_MODULENAME)
  23. _handler = _logging.StreamHandler(sys.stdout)
  24. _handler.setLevel(_logging.DEBUG)
  25. FRMT_LOG_LONG = "[%(name)s][%(levelname)s] >> %(message)s (%(asctime)s; %(filename)s:%(lineno)d)"
  26. _formatter = _logging.Formatter(FRMT_LOG_LONG)
  27. _handler.setFormatter(_formatter)
  28. _LOGGER.addHandler(_handler)
  29. _LOGGER.debug('Loading: {0}.'.format({_MODULENAME}))
  30. # -------------------------------------------------------------------------
  31. # -------------------------------------------------------------------------
  32. def dccsi_test_script(test_str):
  33. """Simple test command for WingIDE
  34. to run in wing: Edit > Command by Name
  35. ^ opens a commanline at bottom of IDE
  36. type: test-script (then return)
  37. ^ commandline now takes entering a Test Str
  38. Test Str: Booyah
  39. ^ a Pop-up dialog will display in wing
  40. """
  41. app = wingapi.gApplication
  42. v = "Product info is: " + str(app.GetProductInfo())
  43. v += "\nAnd you typed: %s" % test_str
  44. wingapi.gApplication.ShowMessageDialog("Test Message", v)
  45. #dccsi_test_script.contexts = [wingapi.kContextNewMenu("Scripts")]
  46. # this will add to a menu in WingIDE
  47. dccsi_test_script.contexts = [
  48. wingapi.kContextNewMenu("DCCsi Scripts"),
  49. wingapi.kContextEditor(),
  50. ]
  51. # -------------------------------------------------------------------------
  52. # bind a hotkey inside Wing that will execute our newly installed Module
  53. # Inside Wing, choose Edit -> Preferences, and on the left, under User Interface, choose Keyboard
  54. # In the center right of the Keyboard section is where you can add "Ccustom Key Bindings" combinations to execute code
  55. # For this test example, I have bound Ctrl+Alt+Shift+T as my key combination for executing dccsi_test_script
  56. ###########################################################################
  57. # Main Code Block, runs this script as main (testing)
  58. # -------------------------------------------------------------------------
  59. if __name__ == '__main__':
  60. # there are not really tests to run here due to this being a list of
  61. # constants for shared use.
  62. _DCCSI_GDEBUG = True
  63. _DCCSI_DEV_MODE = True
  64. _LOGGER.setLevel(_logging.DEBUG) # force debugging
  65. foo = dccsi_test_script("This is a test")