On, Mon Jun 27, 2005, kschnee@xxxxxxxxxx wrote: > >I do wonder though, what/if people have tried as alternatives to event > > driven GUI programming... anyone care to share? > > Some time ago I was building my own widget system. It didn't take over the > program's main control loop. Instead, the main loop (of Pygame) caught > button-click events and said, "For every panel of the GUI, for every > widget in the panel, ask that widget if these coordinates (those of the > mouse click) are within its borders. If so, call that widget's "click" > function." I don't know if that's a _good_ way to handle a GUI, but it's a > slightly different approach, anyway. My first steps with ocempgui went to this direction and caused the whole thing to be very slow. The resolution order was something like this: def receive_signal (self, event): result = False if self.has_other_widgets: for widget in my_widgets: if widget.receive_signal (event): # signal was used by a widget, we can safely stop here... result = True if not result: # widget dependant event reaction code follows here ... return True or False depeding on the code Actually the code differed a bit from the pseudo code above, but it made the whole event distribution really slow. At the moment I am using a simple event distribution system, in which objects register themselves with a signal identifier. When the distributor receives an event, it looks up its identifier and passes it to the matching objects. This has the benefit, that multiple objects can react upon 'globally' used events and so on. However, it is a full event driven mechanism using a callback system, on which user defined callbacks can be connected to widget events. I do not know, if there are actually any UI toolkits out there, which have another approach besides event-driven. Due to the fact that our input devices work in a sort of event driven mode (async polling), how would one create a toolkit, which is not event-driven? And what would be the benefit? Regards Marcus
Attachment:
pgpCjDTgooL3e.pgp
Description: PGP signature