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.

guidemo.py 2.6KB

1 year ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # GUI Demo - just a worker script to invoke all the other demo/test scripts.
  2. import sys
  3. import __main__
  4. import regutil
  5. import win32api
  6. import win32ui
  7. demos = [ # ('Font', 'import fontdemo;fontdemo.FontDemo()'),
  8. ("Open GL Demo", "import openGLDemo;openGLDemo.test()"),
  9. ("Threaded GUI", "import threadedgui;threadedgui.ThreadedDemo()"),
  10. ("Tree View Demo", "import hiertest;hiertest.demoboth()"),
  11. ("3-Way Splitter Window", "import splittst;splittst.demo()"),
  12. ("Custom Toolbars and Tooltips", "import toolbar;toolbar.test()"),
  13. ("Progress Bar", "import progressbar;progressbar.demo()"),
  14. ("Slider Control", "import sliderdemo;sliderdemo.demo()"),
  15. ("Dynamic window creation", "import createwin;createwin.demo()"),
  16. ("Various Dialog demos", "import dlgtest;dlgtest.demo()"),
  17. ("OCX Control Demo", "from ocx import ocxtest;ocxtest.demo()"),
  18. ("OCX Serial Port Demo", "from ocx import ocxserialtest; ocxserialtest.test()"),
  19. (
  20. "IE4 Control Demo",
  21. 'from ocx import webbrowser; webbrowser.Demo("http://www.python.org")',
  22. ),
  23. ]
  24. def demo():
  25. try:
  26. # seeif I can locate the demo files.
  27. import fontdemo
  28. except ImportError:
  29. # else put the demos direectory on the path (if not already)
  30. try:
  31. instPath = regutil.GetRegistryDefaultValue(
  32. regutil.BuildDefaultPythonKey() + "\\InstallPath"
  33. )
  34. except win32api.error:
  35. print(
  36. "The InstallPath can not be located, and the Demos directory is not on the path"
  37. )
  38. instPath = "."
  39. demosDir = win32ui.FullPath(instPath + "\\Demos")
  40. for path in sys.path:
  41. if win32ui.FullPath(path) == demosDir:
  42. break
  43. else:
  44. sys.path.append(demosDir)
  45. import fontdemo
  46. import sys
  47. if "/go" in sys.argv:
  48. for name, cmd in demos:
  49. try:
  50. exec(cmd)
  51. except:
  52. print(
  53. "Demo of %s failed - %s:%s"
  54. % (cmd, sys.exc_info()[0], sys.exc_info()[1])
  55. )
  56. return
  57. # Otherwise allow the user to select the demo to run
  58. import pywin.dialogs.list
  59. while 1:
  60. rc = pywin.dialogs.list.SelectFromLists("Select a Demo", demos, ["Demo Title"])
  61. if rc is None:
  62. break
  63. title, cmd = demos[rc]
  64. try:
  65. exec(cmd)
  66. except:
  67. print(
  68. "Demo of %s failed - %s:%s"
  69. % (title, sys.exc_info()[0], sys.exc_info()[1])
  70. )
  71. if __name__ == __main__.__name__:
  72. import demoutils
  73. if demoutils.NeedGoodGUI():
  74. demo()