This is complicated.
Remember that win32com.client.Dispatch creates a new instance of the specified
class. In your specific case, that creation fails because your MainWindow
constructor expects parameters, and COM doesn't supply any.
You will need to architect this differently. You don't want the COM class to
be a window, because then each Dispatch creates a new window. Instead, have
your main program create the window normally, and have a separate class for
serving COM that gets the window/app instance from a global.
However, there's one more step. By default, COM will launch a new instance of
your server each time instead of connecting to your running server, and that
instance won't be able to get the window/app instance it needs. You need to
run CoRegisterClassObject to register your program as a live server. This is
supported in pythoncom, but I have not used it, so some experimentation will be
required.
ยทยทยท
On Tue, 30 Apr 2002 02:07:58 -0700, "Dave Primmer" <primmer@hotmail.com> wrote:
Has anybody got sample code of a working wxWindows COM server? I'm actually
using PythonCard but if I could see how it was done in wxWindows that might
help. I also have some basic questions about how to connect with a client.
The client would want to attach to a running copy of the COM server the same
way you can use the copy of Word that's running if it's already started.I've got the COM server and client samples from win32all working so I know
how to do the Non-GUI stuff.
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.