[python-win32] Pure Python Pythonwin.exe
Mark Hammond
mhammond at skippinet.com.au
Thu Jun 22 01:50:37 CEST 2006
> Pythonwin the IDE has many fans, and I would like to get it
> working with
> Movable Python [#]_.
Great!
> Pythonwin is launched with 'pythonwin.exe'. Presumably (I speak from
> ignorance here) this uses the registry to determine the
> installed Python.
Nope - it uses some old code that really should die.
>
> When I run Pythonwin.exe on a computer with no installed Python (but a
> working Movpy setup) I get the message :
>
> The application can not locate win32ui.pyd (or python) (126)
> The specified module could not be found.
>
> This is after putting the Pythonwin directory on the path [#]_ - and
> win32ui.pyd exists in the current directory (same directory as
> pythonwin.exe).
That surprises me. win32ui.pyd next to pythonwin.exe should work fine -
that is the first thing checked by the code (which FYI is in
pythonwin/win32uiHostGlue.h)
> I see that the Pythonwin source code is C++, so I guess there
> is no way
> of creating a Pure Python version. :-)
But there is :)
import sys
import win32ui
# importing 'intpyapp' automatically registers an app object.
from pywin.framework import intpyapp
# Remove this script name from sys.argv, else Pythonwin will try and open
it!
sys.argv = sys.argv[:-1]
# Get the MFC "app" object and boot it up.
app = win32ui.GetApp()
app.InitInstance()
app.Run()
app.ExitInstance()
The above code should boot a fully functioning Pythonwin - just execute it
from pythonw.exe and you should be good to go. The only reason I haven't
moved to something like this is that (a) pythonwin.exe already exists, and
(b) having a .exe makes it more obvious to a casual user...
Cheers,
Mark
More information about the Python-win32
mailing list