The simplest way to create an
application object for Scribble is to subclass one of the standard
application objects. The PythonWin application object is implemented
and it derives from the
pywin.framework.app. This base class provides much
of the functionality for an application, so we too will derive our
This makes the application object small and simple. You obviously may
need to enhance certain aspects; in this case, you should use the
pywin.framework modules as a guide. The minimal
application object looks like:
# scribbleApp.py # # The application object for Python. from pywin.framework.app import CApp class ScribbleApplication(CApp): def InitInstance(self): # All we need do is call the base class, # then import our document template. CApp.InitInstance(self) import scribble2 # And create our application object. ScribbleApplication()
To run this, use the following command line:
C:\Scripts> start pythonwin /app scribbleApp.py
An instance of Pythonwin.exe now starts, but uses the application object you defined. Therefore, there’a no Interactive Window, the application doesn’t offer to open .py files, etc. The Scribble application should look like Figure 20.5.
There is also a technique to avoid this command line, but you need a copy of a resource ...