Hi Tim:

After studying the "Python Programming on Win32" book, I was able to make
COM servers . But so far I can pass simple arguments (in both directions)
between Visual Basic and the Python COM server (e.g. integers, strings,
floats and arrays).  I wonder if it's possible to return from the COM
server other kind of objects such as graphics to be used directly from the
.NET program.

To be more precise, I have Python code that uses heavily Numpy and
Matplotlib.  I want to make a COM server that returns images generated with
Matplotlib in order to use within Excel.  The best solution I came out was
to store the Matplotlib's images as .PNG in temporary files.  The COM
server would return their paths so Visual Basic could insert them into the
spreadsheet with its own commands.

Though this solution may work, the images cannot be interactive.  A change
would require the creation of new images each time, store them, reload them
back, etc...  all processes together are expensive.  Therefore, I wish I
could return directly from the COM server an image object that Visual Basic
could handle. Another reason why I want to return an image object directly
is because I want to use remote COM Servers (DCOMs); where the path
solution may not work.

There are two things I think should be in the answer:

1)  How to make image objects in the COM server so the .NET programs can
use.
2) Can Matplotlib create an image that can be used within .NET GUIs.

Sincerely yours,
Diego


2015-03-09 16:55 GMT-05:00 Diego Vélez Torres <divele...@gmail.com>:

> Thank you Tim.  Your advise is been of great help.
>
> I just purchased M. Hammond's "Python Programming on Win32" book.  Though
> a bit old the (1999) still is of great help.  I have been able to make
> simple COM servers so far.  However, I have a question regarding the code
> examples found in his http://starship.python.net/ web site.  Are they
> written in Python 1.x...  or Python 2.x?  I wonder if there are code
> examples written for Python 3.x?
>
> Cheers to all in the mailing list.
>
> 2015-02-24 13:07 GMT-05:00 Tim Roberts <t...@probo.com>:
>
> Diego Vélez Torres wrote:
>> >
>> > I need to make a COM object upon my Python code, so I can call it from
>> > .NET programs (ie. Visual Basic, VB6).  I need the COM object (or DLL)
>> > to be stand alone, because the target PCs where the final programs are
>> > going to run won't have Python installed. I know so far that py2exe
>> > supports this directly:
>> > http://www.py2exe.org/index.cgi/Py2exeAndCtypesComDllServer
>> >
>> > I've tried to make some samples with the given link's instructions,
>> > but I haven't been lucky. I only got empty 'dist' and 'build' folders.
>> > I've search for documentation on the web for quite a long time with no
>> > luck. I realized that I need more information besides the one provided
>> > by the above's link:
>> >
>> >  1. How the Python module that I want to compile must be written?  I
>> >     mean, all functions and classes in module will be available for
>> >     the outside code through the COM Object?  That module needs
>> >     specific lines of code?
>> >
>>
>> What you are trying to create is a COM server.  If you search for
>> "python COM server", you will find many examples.  It does have to be
>> written in a particular way.  You have to identify the functions you
>> want to be exposed, the registry program ID, and the registry GUID in
>> specially named class members (_public_methods_, _reg_progid_,
>> _reg_clsid_).
>>
>> I suggest you make the COM part work first.  Once you have that working,
>> then you can dig in to py2exe to make it standalone.
>>
>> --
>> Tim Roberts, t...@probo.com
>> Providenza & Boekelheide, Inc.
>>
>> _______________________________________________
>> python-win32 mailing list
>> python-win32@python.org
>> https://mail.python.org/mailman/listinfo/python-win32
>>
>
>
>
> --
> Diego Vélez Torres
> divele...@gmail.com
> Teléfono: 098 28 57 58
> Cuenca, Ecuador
>



-- 
Diego Vélez Torres
divele...@gmail.com
Teléfono: 098 28 57 58
Cuenca, Ecuador
_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to