Don't understand wxPython ids

Grant Edwards grante at visi.com
Wed Apr 28 09:42:02 EDT 2004


On 2004-04-28, Doug Holton <insert at spam.here> wrote:

>>>I can only think of one reasn why they chose to use ids in the
>>>first place. Assigning many objects the same id allows you to
>>>use one EVT_* call for those objects. But is that really a
>>>useful feature? Who knows?
>> 
>> That's about the only thing I could think of. The few
>> situations where I'd have wanted to do someting like that I'd
>> gladly put a for-loop iterating over a list of objects in
>> exchange for being able to use single-line of code the other
>> 90% of the time.
>
> Right, there a couple of special cases to think of when
> designing event bindings for a gui toolkit.  One is where you
> want multiple controls to share the same event handler (like a
> button and a menu item that do the same thing).

Just pass the same function to both of them when you create
them?

> Another case is allowing people to change event bindings "on
> the fly", after a window constructor has already been called
> and the window set up.

Provide a method to set the action for an object instance after
it's been created.

Both of these have been SOP in other GUI toolkits for a dog's
age, and I can't figure out any benefit to the ID scheme.
Using an outside function to reach in and torque on the
object's internals seems so un-Pythonesque. But, all sorts of
smart people rave about wxPython, so I thought there must be
some benefit to the ID scheme that I'm missing.

> I proposed some changes similar to you, see this thread:
> http://lists.wxwidgets.org/cgi-bin/ezmlm-cgi?11:sss:23979:200311:dcgnanikkojpgmpdpmio#b
> but nothing came out of it.  I did code up an implementation
> for Wax (http://wiki.wxpython.org/index.cgi/Wax ), but I don't
> know if it was included.


-- 
Grant Edwards                   grante             Yow!  Nice decor!
                                  at               
                               visi.com            



More information about the Python-list mailing list