from sugar.tutorius.properties import * class Event(TPropContainer): source = TUAMProperty() type = TStringProperty("clicked") def __init__(self): TPropContainer.__init__(self) # Providing the hash methods necessary to use events as key # in a dictionary, if new properties are added we should # take them into account here def __hash__(self): return hash(str(self.source) + str(self.type)) def __eq__(self, e2): return self.source == e2.source and self.type == e2.type # Adding methods for pickling and unpickling an object with # properties def __getstate__(self): return self._props.copy() def __setstate__(self, dict): self._props.update(dict) # Nothing more needs to be added, the additional # information is in the object type class ClickedEvent(Event): def __init__(self): Event.__init__(self) self.type = "clicked"