I have two comments. First, it appears that the GUI object elements are hidden. I can create the objects through a CreateName() function, but I cannot otherwise access the objects (take PyCToolBarCtrl for example). It would often be useful to be able to subclass an object (rather than simply wrap it in another class). Is there a reason this isn't supported?
Second, it appears that I have to manually keep track of a lot of settings when building a COM class. It would be much easier if the system automatically accumulated some of these settings during inheritance. As an example, when I inherit a class with a _public_methods_ setting, I should get all of those methods in the new class. Using metaclasses it is possible to have the system do this automatically for you. Is there a reason this hasn't been done yet? Below is a simple example that accumulates several fields, including a new _iid_ field that I invented to simplify my code. I definitely overlooked some fields; a more complete implementation would have to handle attributes for example. class _COMMeta(type) : """ This metaclass will walk all the supers and pull out all the win32com metadata and compose it in the new object. This makes inheritance work how you would expect it to. base._iid_ is accumulated into _com_interfaces_. base._public_methods_ is accumulated. base._com_interfaces_ is accumualted. """ def __new__(cls, name, bases, dict) : def inheritVals(vs, n) : if n not in dict : dict[n] = [] for v in vs : if v not in dict[n] : dict[n].append(v) def inheritBaseList(b, n) : inheritVals(getattr(b, n, []), n) def inheritBaseVal(b, n, ln) : if hasattr(b, n) : inheritVals([getattr(b, n)], ln) for b in bases : inheritBaseVal(b, '_iid_', '_com_interfaces_') inheritBaseList(b, '_com_interfaces_') inheritBaseList(b, '_public_methods_') return type.__new__(cls, name, bases, dict) class COM(object) : __metaclass__ = _COMMeta # the following clases make use of inheritance to simplify # specification... class IOleWindow(COM) : _public_methods_ = ['GetWindow', 'ContextSensitiveHelp'] class IDockingWindow(IOleWindow) : _public_methods_ = ['CloseDW', 'ResizeBorderDW', 'ShowDW'] class IDeskBand(IDockingWindow) : _iid_ = _shell.IID_IDeskBand _public_methods_ = ['GetBandInfo'] Tim Newsham http://www.lava.net/~newsham/ _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32