summaryrefslogtreecommitdiffstats
path: root/itemList.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--itemList.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/itemList.py b/itemList.py
new file mode 100644
index 0000000..527c837
--- /dev/null
+++ b/itemList.py
@@ -0,0 +1,28 @@
+class itemList:
+ def __init__(self, observer):
+ self.data = []
+ self.observer = observer
+
+ def __len__(self):
+ return len(self.data)
+
+ def __getitem__(self, idx):
+ return self.data[idx]
+
+ def __setitem__(self, idx, item):
+ self.data[idx] = item
+
+ def append(self, item):
+ item.observer = self
+ self.data.append(item)
+ self.observer.notifyChange(item)
+
+ def notifyChange(self, sender):
+ self.observer.notifyChange(sender)
+
+ def __add__(self, item):
+ self.append(item)
+ return self
+
+ def __iter__(self):
+ return self.data.__iter__()