[wxpython-dev] Possible to derive from GC?
Robin Dunn
robin at alldunn.com
Thu May 29 18:06:31 PDT 2008
Nitro wrote:
> Hello,
>
> I've send this message yesterday, but it seems it did not get through,
> trying to sending it again.
>
> 1) Is it possible to derive my own class from wx.GraphicsContext or
> should I rather create a GC by itself and then delegate to it?
I expect that either would be ok, but past experience I would guess that
the typical approach in this case would be delegation.
>
> 2) wx.lib.pubsub seems to have a bug. If I change the code at line 860
> class Foo2: to class Foo2(object): then the test breaks, because
> _paramMinCount does not work anymore. Is there any reason to use if
> tests in the _paramMinCount function? This is the code:
>
> if type(callableObject) is InstanceType:
> min, d = _paramMinCountFunc(callableObject.__call__.im_func)
> return min-1, d
> elif ismethod(callableObject):
> min, d = _paramMinCountFunc(callableObject.im_func)
> return min-1, d
> elif isfunction(callableObject):
> return _paramMinCountFunc(callableObject)
> else:
> raise 'Cannot determine type of callable: '+repr(callableObject)
>
> I've rewritten it to the following code which passes the tests, also
> with new-style classes.
>
> try:
> func = callableObject.__call__.im_func
> except AttributeError:
> try:
> func = callableObject.im_func
> except AttributeError:
> try:
> return _paramMinCountFunc(callableObject)
> except exc:
> raise 'Cannot determine type of callable: %s' %
> repr(callableObject)
> else:
> min, d = _paramMinCountFunc(func)
> return min-1, d
> else:
> min, d = _paramMinCountFunc(func)
> return min-1, d
>
> This code looks a bit clumsier than the original one. I don't see a much
> better way right now though.
It would be nice to not have to duplicate the two else clauses at the end.
>
> 3) The pubsub question leads me to another question: How to you want to
> handle SVN access? Should I create a branch which will be merged at the
> end of the project?
Yes. I think you'll need it anyway so you can easily extract out the
changes you've made so you can turn them in to google at the end of the
summer.
> And how should I deal with patches/fixes which are not related to
> FloatCanvas (like the one to pubsub above)? Send in a patch on this
> mailing list and somebody reviews and accepts it?
Yes, or submit a ticket at trac.wxwidgets.org.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-dev
mailing list