demoutils.py :  » Windows » pyExcelerator » pywin32-214 » pythonwin » pywin » Demos » app » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Windows » pyExcelerator 
pyExcelerator » pywin32 214 » pythonwin » pywin » Demos » app » demoutils.py
# Utilities for the demos

import sys, win32api, win32con, win32ui

NotScriptMsg = """\
This demo program is not designed to be run as a Script, but is
probably used by some other test program.  Please try another demo.
"""

NeedGUIMsg = """\
This demo program can only be run from inside of Pythonwin

You must start Pythonwin, and select 'Run' from the toolbar or File menu
"""


NeedAppMsg = """\
This demo program is a 'Pythonwin Application'.

It is more demo code than an example of Pythonwin's capabilities.

To run it, you must execute the command:
pythonwin.exe /app "%s"

Would you like to execute it now?
"""

def NotAScript():
  import win32ui
  win32ui.MessageBox(NotScriptMsg, "Demos")

def NeedGoodGUI():
  from pywin.framework.app import HaveGoodGUI
  rc = HaveGoodGUI()
  if not rc:
    win32ui.MessageBox(NeedGUIMsg, "Demos")
  return rc

def NeedApp():
  import win32ui
  rc = win32ui.MessageBox(NeedAppMsg % sys.argv[0], "Demos", win32con.MB_YESNO)
  if rc==win32con.IDYES:
    try:
      parent = win32ui.GetMainFrame().GetSafeHwnd()
      win32api.ShellExecute(parent, None, 'pythonwin.exe', '/app "%s"' % sys.argv[0], None, 1)
    except win32api.error, details:
      win32ui.MessageBox("Error executing command - %s" % (details), "Demos")


if __name__=='__main__':
  import demoutils
  demoutils.NotAScript()
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.