473,395 Members | 1,688 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Dispatch, DispatchWithEvents

I'm currently reinventing the wheel ;-), implementing 'clones' for the
win32com.client.Dispatch and DispatchWithEvents functions using ctypes.
It works fairly well, although the more complicated data types like
SAFEARRAY or RECORD are not yet implemented.

The win32com.client versions of these functions require makepy support
(for DispatchWithEvents), and create this on demand. The ctypes
versions don't require something similar, they are using the ITypeComp
interface at runtime to bind methods, properties, and constants on
demand, for events support they use either IProvideClassInfo2 to find
the outgoing interface, or iterate through the type library to find the
type info and finally ITypeComp for the default outgoing interface.

For my own sake, I'm trying to keep the ctypes version as compatible as
possible to the win32com versions, although I'm not happy by some of the
design decisions Mark Hammond or whoever wrote this stuff made.

First, constants defined in the type libraries are exposed in the
win32com.client.constants instance, which is internally a sequence of
dictionaries. Wouldn't it be better to have the constants available in
the object returned by the Dispatch() call itself, maybe in a _constants
property? I'm also wondering how VB does this...

My second 'complaint' is about the event handlers. It seems win32com
prepends 'On' to the method handler names if the method itself, as
defined in the type library, doesn't already start with 'On'. Take
Internetexplorer as an example. The DWebBrowserEvents2 outgoing
interface has methods named "BeforeNavigate2", "NavigateComplete2", and
"OnQuit". The handlers in Python then must be named
"OnBeforeNavigate2", "OnNavigateComplete2", and "OnQuit". The method
names look nice in the Python class implementation, and their templates
are also available as commented out code in the makepy generated files,
but looking at the Internet Explorer type library with Oleview, I find
this very confusing. What is the reason that it was chosen this way?

Thomas
Jul 18 '05 #1
0 1943

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: RJ | last post by:
Hi, I've been going over the Quick Start to Client side COM and Python and many other sources, but cannot find an example that will get my com/ActiveX .ocx USB device driver imported. The Excel...
0
by: ccahoon | last post by:
Traceback (most recent call last): File "windowedfax.py", line 223, in OnClick self.iexplore = DispatchWithEvents("InternetExplorer.Application", eventHandling) File...
0
by: Chandra | last post by:
Hi, I tried the following: >>> from win32com.client import DispatchWithEvents >>> class BackupEvent: .... def OnPercentComplete(self, sMessage, nPercent): .... print sMessage,...
3
by: Dan Vogel | last post by:
I'd like to find an elegant solution to the problem of calling a certain function based on the types of two parameters. In my case, the functions compute the distance between different types of...
0
by: puff | last post by:
I'm working on a com automation project involving IE (yes, I know about Pamie). I connect to IE through DispatchWithEvents, start a navigation, and then loop calling PumpWaitingMessages. I see...
3
by: tyler.schlosser | last post by:
Hi there, I am trying to launch a program called AmiBroker using the command: AB = win32com.client.Dispatch("Broker.Application") However, I have a dual-core CPU and would like to launch two...
4
by: mirandacascade | last post by:
O/S : Win2K vsn of Python: 2.4 Hoping to find information that provide information about error messages being encountered. Pythonwin session: Traceback (most recent call last): File...
5
by: markww | last post by:
Hi, Can someone explain to me what static and dynamic dispatch are and what the difference is between the two? Do this even occurr in C++? Thanks
3
by: Tigera | last post by:
Greetings, I too have succumbed to the perhaps foolish urge to write a video game, and I have been struggling with the implementation of multiple dispatch. I read through "More Effective C++"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.