Re: COM: Minimal example of a custom server working with DispatchWithEvents()

William Belanger <[email protected]>
Newsgroups gmane.comp.python.windows
Message-ID <CAEv6-3vbYFG+wph6S75qZ0VyggeyvN44MEeKnuELOO5HOkhu6A@mail.gmail.com>
Hi,


There is no typelib file unfortunately. The interface needs to communicate
with Antidote's API by creating a COM server which exposes the methods
defined in the AdapteurAntidote class.


The problem is that the widget queried (a QTextEdit) is instantiated in
another class (MainWindow), and I cannot attribute a "parent" to the
dispatched COM object (self.server), as it raises either an AttributeError
or a TypeError, depending on its declaration in __public_attrs__.


From the documentation, I thought I needed to use DispatchWithEvents to
handle the events in a separate "sink" class (ImplementationAntidote) that
would behave more like a generic python object. Is there any other way to
achieve this? It is quite a trivial feature so I assume it is possible to
do so?


Best,

Will

Le mer. 28 juil. 2021 à 04:25, Mark Hammond <[email protected]> a
écrit :

>
> On 28/07/2021 7:58 am, William Belanger wrote:
> > Hi everyone,
> >
> >
> > I'm trying to make a cross-platform Python interface for a third-party
> > API (Druide Antidote). The D-Bus part is done and working
> > (https://gitlab.com/-/snippets/2151173
> > <https://gitlab.com/-/snippets/2151173>), it consist of a server
> adapter
> > (AdaptateurAntidote), which relay the events to an handler class
> > (ImplementationAntidote).
> >
> >     Traceback (most recent call last):
> >
> >     File
> >
>  "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\win32com\client\__init__.py",
> >     line 256, in DispatchWithEvents
> >
> >     ti = disp._oleobj_.GetTypeInfo()
> >
> >     pywintypes.com_error: (-2147352567, 'Exception occurred.', None,
> None)
>
> DispatchWithEvents creates a COM object, then gets the typeinfo needed
> to implement the interfaces defined for events - but this COM object is
> failing to provide that type info at runtime. It might still have a .tlb
> available though, and if it does, you can run `makepy.py` once and the
> snippet should work. The typelib can also live in a .dll, but I've never
> heard of Antidote so have no better suggestions.
>
> Cheers,
>
> Mark
>

_______________________________________________
python-win32 mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-win32
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.