[wxPython-users] Re: some question about custom events ...

Stef Mientki s.mientki at ru.nl
Sat Jun 30 10:42:13 PDT 2007



Christian K wrote:
> Stef Mientki wrote:
>   
>> hello,
>>
>> I couldn't find much consistent information about custom events on the web,
>> the best I found was: http://wiki.wxpython.org/CustomEventClasses.
>>     
>
> This should be sufficient.
>   
for you ;-)
>   
>> Although I succeeded in my goal, I'm still left with a few questions:
>>
>> 1.  What's the difference between NewEvent and NewCommandEvent ?
>> I somewhere read that only one of them can propagate,
>> whatever that means ?
>>     
>
> It means that you have to bind directly to those controls, which send plain
> Events in order to receive them, whereas CommandEvents can be received by
> binding to any parent control. Here propagation means, that a CommandEvent will
> travel up the hierarchy of nested controls and an Event will not.
>   
thanks Cristian,
that explains.

>> I found out that NewCommandEvent is not allowed to have arbitrary data
>> attached.
>>     
>
> Then I think it's a bug. Are you sure?
>   
I'm not sure, but this works:
  JALsPy_Properties_Event, EVT_JALSPY_PROPERTIES_CHANGED = 
wx.lib.newevent.NewEvent()
  new_evt = JALsPy_Properties_Event( attr1="hello", attr2=654 )

And this gives an error:
  JALsPy_Properties_Event, EVT_JALSPY_PROPERTIES_CHANGED = 
wx.lib.newevent.NewCommandEvent()
  new_evt = JALsPy_Properties_Event( attr1="hello", attr2=654 )

Traceback (most recent call last):
  File "D:\data_to_test\JALsPy\JALsPy_properties.py", line 165, in 
OnEditorChange
    new_evt = JALsPy_Properties_Event( attr1="hello", attr2=654 )
TypeError: __init__() takes exactly 2 non-keyword arguments (1 given)

>   
>> 2.   Why in wx, sometimes is used  "parent" and sometimes "Parent" ?
>>     
>
> What do you mean? Variable names? They are arbitrary.
>   
Yes,
but I think programming was more "reasoning"  than "knowing"  ;-)

cheers,
Stef Mientki





More information about the wxpython-users mailing list