[python-win32] Pure Python Pythonwin.exe

Michael Foord fuzzyman at voidspace.org.uk
Thu Jun 22 15:02:30 CEST 2006


Mark Hammond wrote:
>> 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)
>
>   
Maybe a generic error message when it fails to find Python ? Seeing as 
you posted Python code below I lost my motivation to go poking round in 
C++ files. :-)


>> 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 :)
>
>   
This is great, it runs fine with Movable Python. (Although I have yet to 
find a machine *without* Python installed to try it properly, I need to 
get VMWare running again.)

When it runs for the first time it prints the following message to the 
console (but works fine) :

    Failed to connect to Pythonwin|System. Error 0

Is this because there is no currently running version of pythonwin for 
it to connect to ?

Anyway, many thanks.

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml


> 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