Win32uiHostGlue

Mark Hammond mhammond at skippinet.com.au
Tue May 28 19:09:20 EDT 2002


Michael Ingram wrote:
> So I guess I'll accept my Klebold of the month award now.
> 
> I don't seem to be capable of grasping the concept of Win32uiHostGlue,
> Win32ui or how I can leverage these tools from my MFC application.
> 
> From Win32uiHostGlue.h rev.1.7 I've derived class PY_HostGlue (below).
>  From "Embedding Pythonwin", I've pretty much copied initscore.py
> (init.py, also below).
> 
> If I import init.py from Pythonwin, the script seems to import
> properly.  And if I type the command: init.app.InitInstance() the
> interactive window is indeed minimized.
> 
> Now, from within my MFC application, I can call
> glue.DynamicApplication("import init") without any errors and stepping
> through PY_HostGlue.h shows that Win32uiApplicationInit() is called
> succesfully.  But from this point on I'm not really sure what I have,
> or how to use it...sorry).
> 
> Any subsequent calls to the interpreter e.g.
> PyRun_SimpleString("init.app.InitInstance()") generates a Run Time
> Error, regardless of whether it's called from the MFC application or
> from within the glue code.
> 

The idea is that your application will "bootstrap" itself.  For example, 
your application's InitInstance() method may choose to create additional 
windows.  Pythonwin, for example, creates the interactive window.

In general, your C++ MFC code shouldn't need to do much Python work, but 
instead your MFC C++ code should generally be called from Python.  Thus, 
your C++ code is exposed as an extension module, and your bootstrapped 
Python code can then make whatever calls it needs via this module.

Mark.




More information about the Python-list mailing list