cool-RR wrote:
I don't see how this is different from any other case in programming
when you have to give your object a specific name in order for it to
be used. For example, you want a constructor? You have to call it
`__init__`. You want something to happen before your dialog gets
show-modalled? You have to name your new method `ShowModal` and do
your action there.
Well, those cases ARE different. Those are fixed, well-publicized, and
well-known names. You are talking about inventing new names based on a
set of heuristics. I need to understand those heuristics completely in
order to predict what name I should be using.
I can call my version of "ShowModal" anything I want, like
"BlastItUpThere". That will still work, as long as I call it by that
name. That's all under my control. You're hooking up names without my
involvement. Not good or bad, but different cases.
In my system you just do `def _on_ok_button` and then it's bound to
`wx.EVT_BUTTON` from `self.ok_button`. (This should answer your
question as well Tim.)
Are you planning to generate the Bind calls based on the functions you
find, or you planning to search for controls and then generate the
function names? Remember there are other events -- I might want to have
focus in and focus out handlers for a button, as well as a "clicked"
handler. In many cases, the callback function name will need to include
both the event and the control name (_on_button_ok_button,
_on_set_focus_ok_button, _on_kill_focus_ok_button). MFC and VB both do
things this way.
This requires that all of my controls be instance members, as opposed to
locals. This also requires that I adopt to your naming scheme (that is,
"on_ok_button" as opposed to "onOkButton").
I don't see how my idea is less legitimate than these examples.
I'm not sure anyone ever called it illegitimate. However, like Chris,
my experience tells me that the corner conditions and special cases mean
that you will end up writing more code with your scheme than you would
have calling self.Bind. I think it would be interesting for you to take
a whack at it and see what happens, however. It's an interesting concept.
···
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.