[python-win32] Compiling a Python Windows application

Bob Gailer bgailer at alum.rpi.edu
Fri Nov 24 18:49:52 CET 2006


Bokverket wrote:
> I wrote:
>
> If you don't want to distribute the Python interpreter along with your app,
> Is there a well-working way of compiling/byte-coding/whatever a Python app
> and call it from within Microsoft Word? What run-time is needed?
>
> Tim replied:
> The Python interpreter *is* the run-time.  You need to deploy the
> interpreter in order to run Python scripts.  Packages like py2exe allow
> you to that in a way that is largely transparent to the end user.
>
>
> Thanks Tim for your answer, what about reaching Python from within Word? 
> What I would like is a new menu in Word, clicking on a menu item would bring 
> up a dialog box where the user sets some parameters , clicking OK is to 
> start the Python app.   The open Word document and the parameters need to be 
> made available to the app.
>
> Do I have to go through Visual Basic macros to do this 
One does Word automation using VB. AFAIK there is no other way.
We can help guide you thru the steps (this is how I would do it):
- create UserForm(s) to collect parameters
- create a custom menu using Tools -> Customize with each item tied to a 
macro
Each macro would open a userform. The click event of the OK button on 
the UserForm would shell Python.

A slight alternative would be to have the macros call Windows Scripting 
Host files that would present the dialog and shell Python.

A bigger alternative would be to have the macros shell Python and write 
the parameter collecting mechanism in Python.

> or is there a _good_ way?!
I take it that you don't enjoy VB programming. It certainly is more 
wordy and less flexible than Python, but for relatively small tasks like 
this not a big deal. I've written 10s of thousands of lines of VBA for 
Word and Access. Of course I prefer Python when I can use it.

-- 
Bob Gailer
510-978-4454



More information about the Python-win32 mailing list