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