Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tutorius/events.py
diff options
context:
space:
mode:
authorVincent Vinet <vince.vinet@gmail.com>2009-09-20 14:02:06 (GMT)
committer Vincent Vinet <vince.vinet@gmail.com>2009-10-01 15:27:42 (GMT)
commit06db96e9dd4172484f9a028d0b5a1bc7c97664ee (patch)
tree6a87ff1cac650baf307719d99c7ee14a1ee3d5ec /tutorius/events.py
parent09b2ea3369df967309f030f9196c2f9861bc1b2c (diff)
merge in erick's TProbe work, add a very basic unit test
Diffstat (limited to 'tutorius/events.py')
-rw-r--r--tutorius/events.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tutorius/events.py b/tutorius/events.py
new file mode 100644
index 0000000..bf0a8b9
--- /dev/null
+++ b/tutorius/events.py
@@ -0,0 +1,36 @@
+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"
+