Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tutorius/events.py
blob: bf0a8b99adbcf4c3a5f1cb1891582130075a25a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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"