| ★ wanayoo — archive 1999 http://www.python.org/ftp/python/pythonwin/html/pythonwin/EmbeddingWin32ui.html | Nouvelle recherche | Portail wanayoo |
Using
Pythonwin in an external project. Pythonwin is distributed as 2 key components - Pythonwin.exe and win32ui.pyd. Win32ui.pyd contains all the user interface in Pythonwin - Pythonwin.exe is a simple "wrapper" .exe that hosts win32ui.pyd.
This document describes how to imbed the win32ui extension module in your own application.
The biggest limitations you will find are that a host application must
You must sub-class a Win32uiHostGlue class. This class is used as a glue between win32ui.pyd and the host .exe, and is defined in Win32uiHostGlue.h
Currently, this consists of about 5 methods that must be called. The principle is that the Application must hook certain handlers, and delegate them to the HostGlue class. This will ensure the appropriate Win32ui internals are called.
The only documentation for this is below, where Pythonwin's use of this class is described.
This section describes how Pythonwin.exe implements the above mechanism.
// The one and only Glue object.
Win32uiHostGlue NEAR glue;
BOOL CPythonWinApp::InitApplication()
{
m_pDocManager = new CDocManager();
if (!CWinApp::InitApplication())
return FALSE;
if (!glue.DynamicApplicationInit("import startup"))
return FALSE;
return TRUE;
}
Note the "import startup". This is the
command that kicks off the entire Pythonwin session. The module
startup.py creates the application objects etc.
BOOL CPythonWinApp::InitApplication()
{
m_pDocManager = new CDocManager();
if (!CWinApp::InitApplication())
return FALSE;
if (!glue.DynamicApplicationInit("import startup"))
return FALSE;
return TRUE;
}