[Python-3000] GUI events

Antoine Pitrou solipsis at pitrou.net
Wed May 10 03:02:22 CEST 2006


Le mardi 09 mai 2006 à 20:44 -0400, Jim Jewett a écrit :
> Events (or slots, or signals) which are internal to the GUI do not
> need to be exposed.
> When it is needed, translating between from a signal to an event or an
> event to a slot may not be the most graceful solution, but it will
> work.

Speaking of events, the .Net idiom for this seems quite nice. 
In short it looks like:

---
def my_on_clicked_button(possible_args):
    ...

button = gui.Button(...)
button.on_clicked += my_on_clicked_button
---

Of course in C# you have a lot of boilerplate (overly verbose type
declarations, etc.), but this is the idea.

Has anyone had any experience with this idiom? Are there any drawbacks?
It looks more elegant than inheritance and overriding methods to me.
(when I have to inherit a library-supplied class, I'm always worried
that I could override existing methods/attributes by mistake and trigger
unexpected behaviour. Even you are careful there is still the risk that
a later library version adds a property or method whose name clashes
with one of yours)

Regards

Antoine.




More information about the Python-3000 mailing list