I am still struggling with PyActiveScripting COM events. Is there a way to "step into" the framework code while running the C++ host? I found PyDump - how can I make use of it?
Thank you Wuping ------ Original Message ------ From "Mark Hammond" <mhamm...@skippinet.com.au<mailto:mhamm...@skippinet.com.au>> To "Wuping Xin" <wup...@caliper.com<mailto:wup...@caliper.com>> Cc "Python-win32@python.org<mailto:Python-win32@python.org>" <Python-win32@python.org<mailto:Python-win32@python.org>> Date 3/14/2023 12:47:27 AM Subject Re: [python-win32] How to enable events for Python Active Scripting? WARNING EXTERNAL EMAIL Feel free to put a PR up! Cheers, Mark On 14/03/2023 3:10 pm, Wuping Xin wrote: Thank you again Mark. In framework.py, Line 223 - Line 235, I see that it only searches for [source, default] interface on the coclass. That means, multiple event interface is NOT supported for now. I think I'll have to use "win32com.client.connect.SimpleConnection()" to manually create the Source/EventSink connection. Wuping ------ Original Message ------ From "Mark Hammond" <mhamm...@skippinet.com.au<mailto:mhamm...@skippinet.com.au>> To "Wuping Xin" <wup...@caliper.com<mailto:wup...@caliper.com>> Cc "Python-win32@python.org<mailto:Python-win32@python.org>" <Python-win32@python.org<mailto:Python-win32@python.org>> Date 3/13/2023 10:55:03 PM Subject Re: [python-win32] How to enable events for Python Active Scripting? WARNING EXTERNAL EMAIL IIRC, each of these objects is a "named item" - so whatever name you use when you call AddNamedItem() is the prefix and the suffix is the name of the function on the event interface. I'm really not sure how multiple event interfaces are supported, if at all. Cheers, Mark On 14/03/2023 1:12 pm, Wuping Xin wrote: Hi Mark, - "you would define a function called "ObjectName_EventName" Thank you again! This is valuable info. In the following pseudo-code, the Host COM Object implements TWO Events interfaces. How should I defined relevant event sink functions? For example, if the object instance is named "MyHostObject", should I just directly define the following event sink functions? MyHostObject.Do_A_Event() MyHostObject.Do_B_Event() MyHostObject.Do_C_Event() MyHostObject.Do_D_Event() interface _IMondayEvents { Do_A_Event; Do_B_event; } interface _ITuesdayEvents { Do_C_Event; Do_D_event; } coclass HostApplication { [default] interface IHostApplication; [source] interface _IMondayEvents; [source] interface _ITuesdayEvents; }; ------ Original Message ------ From "Mark Hammond" <mhamm...@skippinet.com.au<mailto:mhamm...@skippinet.com.au>> To "Wuping Xin" <wup...@caliper.com<mailto:wup...@caliper.com>> Cc "Python-win32@python.org<mailto:Python-win32@python.org>" <Python-win32@python.org<mailto:Python-win32@python.org>> Date 3/13/2023 8:45:37 PM Subject Re: [python-win32] How to enable events for Python Active Scripting? WARNING EXTERNAL EMAIL [adding the list back in] I'm still not quite sure what you are trying to do. If you are trying to use Active Scripting, then things should "just work" in the same way they work for other Active Scripting languages. The IE demos show us handling events from IE. This all ties together with interfaces described in typelibs and using IConnectionPoint etc. In this world you don't implement Python classes which derive from EventSink or ScriptItem, you would define a function called "ObjectName_EventName" - eg the "Image_OnClick()" you will find in mousetrack.htm. If you are just trying to use the IConnectionPoint etc without the Active Scripting framework, then your best bet is to check out win32com\demos\connect.py, and specifically how it uses "win32com.client.connect.SimpleConnection()" with the CLSID of an object implementing the interface which fires the events. I'm afraid it has been many years since I've worked on anything related to COM or events, so I really don't have great insights into the finer details. I've also no additional demos - everything relevant I have is in the repo. Cheers, Mark On 14/03/2023 10:41 am, Wuping Xin wrote: Hi Mark, Thank you again for your suggestion. Here is my use case: 1. C++ Host Application, which exposes a COM object model (with COM events). 2. Users are expected to write Python script to interact with the COM object model. Following your advice, I read the following source files - win32comext\axscript\client\framework.py - win32comext\axscript\test\testHost.py But I am still somewhat unsure how to create event sinks at the Python script side. - Should I add a user-define Python class that inherits from EventSink or ScriptItem? Do you think you might be able to provide more hints or it would be great if there is an example to illustrate this? Much appreciated! Wuping Xin, PE, PhD Chief Technology Officer | Caliper Corporation ||||||||||||||||||||||||||||||||||||||||||||||||||||| 1172 Beacon St, Ste 300 • Newton MA 02461 USA Mobile: 617-564-1676 • Main: 617-527-4700 ------ Original Message ------ From "Mark Hammond" <mhamm...@skippinet.com.au><mailto:mhamm...@skippinet.com.au> To "Wuping Xin" <oudou...@gmail.com><mailto:oudou...@gmail.com>; python-win32@python.org<mailto:python-win32@python.org> Date 3/12/2023 10:54:23 PM Subject Re: [python-win32] How to enable events for Python Active Scripting? It's difficult to know what exactly you mean, but if it is how to use IConnectionPoint etc from Python in general, then you should check out the following files in the distribution: com\win32com\demos\connect.py com\win32com\server\connect.py com\win32com\client\connect.py If it is about the use of these interfaces specifically with ActiveScripting, then you should find win32comext\axscript\test\testHost.py useful. win32comext\axscript\client\framework.py is where the implementation of Active Scripting's event handling is implemented - eg, see the functions Connect, CreateConnections, ConnectEventHandlers etc in that file. HTH, Mark On 13/03/2023 1:05 am, Wuping Xin wrote: I have a host application that uses Python Active Scripting. That host application implements IConnectionPoint / IConnectionPointContainers etc, and I am able to set COM event callbacks in C++. But I am having a hard time to figure out how to set COM event callback with Python Active Scripting - I bought the book "/Python Programming On Win32, but /it doesn't provide much information about//Python Active Scripting COM events. Need help and much appreciate any advice. Wu _______________________________________________ python-win32 mailing list python-win32@python.org<mailto:python-win32@python.org> https://mail.python.org/mailman/listinfo/python-win32<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Fpython-win32&data=05%7C01%7Cwuping%40caliper.com%7C7d87c4d15ba64e939c1b08db244739e1%7Cf6e1fbdcbea34b468ff6deddc0d9eabd%7C1%7C0%7C638143660570452146%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=0PXEYRfGKAql1ihZ6ynbk%2Bqak2yMBp9qPnoMXhdKuHo%3D&reserved=0> >
_______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32