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.

demoutils.py 1.5KB

1 year ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # Utilities for the demos
  2. import sys
  3. import win32api
  4. import win32con
  5. import win32ui
  6. NotScriptMsg = """\
  7. This demo program is not designed to be run as a Script, but is
  8. probably used by some other test program. Please try another demo.
  9. """
  10. NeedGUIMsg = """\
  11. This demo program can only be run from inside of Pythonwin
  12. You must start Pythonwin, and select 'Run' from the toolbar or File menu
  13. """
  14. NeedAppMsg = """\
  15. This demo program is a 'Pythonwin Application'.
  16. It is more demo code than an example of Pythonwin's capabilities.
  17. To run it, you must execute the command:
  18. pythonwin.exe /app "%s"
  19. Would you like to execute it now?
  20. """
  21. def NotAScript():
  22. import win32ui
  23. win32ui.MessageBox(NotScriptMsg, "Demos")
  24. def NeedGoodGUI():
  25. from pywin.framework.app import HaveGoodGUI
  26. rc = HaveGoodGUI()
  27. if not rc:
  28. win32ui.MessageBox(NeedGUIMsg, "Demos")
  29. return rc
  30. def NeedApp():
  31. import win32ui
  32. rc = win32ui.MessageBox(NeedAppMsg % sys.argv[0], "Demos", win32con.MB_YESNO)
  33. if rc == win32con.IDYES:
  34. try:
  35. parent = win32ui.GetMainFrame().GetSafeHwnd()
  36. win32api.ShellExecute(
  37. parent, None, "pythonwin.exe", '/app "%s"' % sys.argv[0], None, 1
  38. )
  39. except win32api.error as details:
  40. win32ui.MessageBox("Error executing command - %s" % (details), "Demos")
  41. from pywin.framework.app import HaveGoodGUI
  42. if __name__ == "__main__":
  43. import demoutils
  44. demoutils.NotAScript()