On Oct 14, 2011, at 9:28 AM, Chris G wrote:
>> Yes, it would be. In much the same way that Python will automatically
>> supply an instance reference as the first parameter when an instance method
>> is called, Dabo will supply an event object parameter to handlers as the
>> second.
>
> OK, but then "... Event handlers need to be written to accept a single
> event object parameter." is misleading isn't it, there are two
> parameters. That's part of my question and, secondly, is that second
> (dictionary) parameter documented anywhere?
It depends. Handlers can be regular methods, or they can be instance
methods of the control itself. If they are regular methods, the event parameter
is supplied. If they are instance methods, the event parameter is supplied, but
Python also supplies the instance reference, making two. This is a common
Python idiom.
> OK, but I don't *really* want to stop the default behaviour. :-) I
> was just trying to understand how it works.
I didn't assume you wanted to; just wanted to explain that it was
possible.
> Does the default handler
> for the text box take all the printing characters and put them in the
> box and then pass any non-handled characters to any further event
> handlers that one implements?
No. The handler in your code gets first crack at the event, and unless
you call evt.stop(), the native handler then deals with the event.
> Where does this have to go in my AppWizard generated code?
I'll let Paul handle that question - I haven't worked with AppWizard
code in a very long time.
> It doesn't
> work when I put it in ui/GrdLog.py (the application is called log). If
> I put:-
>
> self.bindEvent(dabo.dEvents.KeyDown, self.handleKey)
>
> then handleKey gets called for non-printing characters but not for
> printing characters. If I put:-
>
> self.bindEvent(dabo.dEvents.KeyChar, self.handleKey)
>
> then handleKey *never* gets called for any entered character.
>
> I suspect that I'm calling bindEvent() from the wrong place?
It figures that you would start with the most complex control! ;-)
Grids are composed of several controls internally, making coordinating
events difficult. If you then make the grid editable, then the temporary
control that appears to handle the editing also has to deal with the events
involved. When you edit in a grid, under the hood wxPython creates a textbox
that appears where the grid cell is, and which then sends the result of your
editing back to the grid. That's why grid editing is discouraged for all but
the most straightforward cases.
If you really need to go down this road, grid columns can have a
CustomEditorClass, which is a control class that you define that is shown when
that column is being edited. As you might imagine, this is somewhat complex and
is probably not the place for someone new to Dabo to start; it's more of a
power user feature.
-- 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]