Antoine Pitrou wrote: > button = gui.Button(...) > button.on_clicked += my_on_clicked_button
> Has anyone had any experience with this idiom? Are there any drawbacks? > It looks more elegant than inheritance and overriding methods to me. PyGUI currently has a form of this, except that you only get to plug in one handler at a time. This is enough to avoid the need for subclassing in many cases, though. I could support multiple handlers, but it would make things substantially more complicated, and I'm not convinced it's worth it. I rarely find the need to install multiple independent handlers for an event. Often I want to *override* a handler and gain complete control, and then I find that multiple-handler systems (e.g. gtk signals) tend to hinder more than they help. > (when I have to inherit a library-supplied class, I'm always worried > that I could override existing methods/attributes by mistake PyGUI uses names starting with underscores for all its internal attribute names. I could use an even stricter convention for internal names if people thought it would be of benefit. Many of PyGUI's classes are designed to be used by inheritance (e.g. Window, View). -- Greg _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
