Event triggering and weak references
darrell at dorb.com
Sun Apr 16 16:22:36 CEST 2000
> This is what I would like to do:
> Imagine I could have two or more Widgets open displaying a car speed
> say a numerical and a graphic display, if this car speed changes (ex. some
> one pushes the break), I would like to have any open widget on this value
> updated (on opening each window would register interest with this car
Here's an approach that requires changes to the watched class.
Maybe some of Robert's method wrappers would be nice.
Being able to hook a method from the outside is a powerful way to decouple
code. But wouldn't it be harder to understand? Sometimes I think C++ is
difficult because only when you trace though it do you realize where it's
going. Having the watched thing provide an explicit signal seems easier to
Don't know if you can call this weak references but they can't cause cycles.
The use of strings to avoid cycles may not be required soon with the new GC
uthreads.py might be cool for this sort of thing, somehow?
Thanks for the Sunday morning puzzle.
# Only strings are stored
def regWatch(self, obs, watch):
obs : observer name string
watch : string name of thing to watch
def unregWatch(self, obs, watch):
def regWatchAble(self, watch):
def unregWatchAble(self, obs, watch):
for i in l:
for k in Watches._Obs.keys():
"""Something to watch"""
def __init__(self, watches,name):
# 'w1' would be more like 'moduleName.w1'
Signaled: <__main__.W1 instance at 895b48>
More information about the Python-list