On Sep 21, 2008, at 7:01 AM, Sibylle Koczian wrote:
> First a little nit-picking: shouldn't the second form be
> "super(Foo, self).method()"?
Yeah, that's correct. I must have written that response quickly
without proofreading it.
> Second: I know, having tried it, that those method definitions are
> necessary.
> Without them, only with "OnHit=self.first" etc., the buttons won't do
> anything. But why? They don't do anything but call the base class
> methods
> with the same name. I thought if a method is called on a class
> instance and
> not found in the class definition it's searched for in the base
> class(es)
> anyway.
>
> What did I overlook?
Events need to be bound to event handlers; the only requirement for a
method to be an event handler is that it accept the event object
passed to it. In a form, first(), next(), etc., are methods, not event
handlers. What is in that code is a trick that changes an object-level
method to an event handler. I think that this sort of coding is
confusing and should be avoided. Instead, I would prefer something
more explicit:
btn = dabo.ui.dButton("First", OnHit=self.onFirst)
def onFirst(self, evt):
self.first()
Using this, the distinction between the event handler and the method
that is called by the handler is clear. Also, it will not break any
other code in the form that may call self.first(), since that method
now expects an event object.
-- Ed Leafe
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]