From 08a531c203dbd44f97a57ef098ed12742d7e6f8e Mon Sep 17 00:00:00 2001 From: Walther Neuper Date: Mon, 14 Dec 2009 17:50:39 +0000 Subject: preps done for new Learner selecting from Collection, view ok --- diff --git a/ReckonPrimer.activity/collection.py b/ReckonPrimer.activity/collection.py index e303e21..63b08f2 100644 --- a/ReckonPrimer.activity/collection.py +++ b/ReckonPrimer.activity/collection.py @@ -55,8 +55,8 @@ class Collection: TODO: define once at startup of RP ?""" #WN.LV diesen Code ersetzen: collection_table.attach(self.colldata,... self.topic_box = gtk.HBox(True, 0) - #self._display.collection_table.attach(self.topic_box, 0, 6, 0, 1) - self._display.collection_table.attach(self.topic_box, 0, 6, 5, 6) + self._display.collection_table.attach(self.topic_box, 0, 6, 0, 1) + #self._display.collection_table.attach(self.topic_box, 0, 6, 5, 6) def set_coll_gui(self): """ Set gui-elements according to Collection.data. """ diff --git a/ReckonPrimer.tests/collection/test_collection_MM091214.py b/ReckonPrimer.tests/collection/test_collection_MM091214.py new file mode 100644 index 0000000..8e1134b --- /dev/null +++ b/ReckonPrimer.tests/collection/test_collection_MM091214.py @@ -0,0 +1,63 @@ +# -*- coding: UTF8 -*- +"""tests on collection class""" + +class collection: + + def __init__(self, name): + self._data = [] + self._name = name + self._pic = "" + + def add(self, x): + self._data.append(x) + + def delete(self, n): + del self._data[n] + + def show(self, top): + """ prints recursively all elements of this collection """ + #only for test reasons + print("**********") + print "collection: ", self._name + print "elements:" + for el in self._data: + el.show(False) + print "---- end of ", self._name + if top: + print # print an empty line after the last element + +class task: + def __init__(self, name): + self._name = name + def show(self, top): + print "task: ", self._name + + +root = collection("root") +c1 = collection("c1") +t1 = task("t1") +t2 = task("t2") +c1.add(t1) +c1.add(t2) +c3 = collection("c3") +c3.add(t2) +c3.add(t1) +c1.add(c3) +root.add(c1) +# created: [[t1, t2, [t2, t1]]] +root.show(True) + +# Versuch in einer Schleife dynamisch auf ein mit Koordinaten spezifiertes Object zuzugreifen +co=[0,2] # Koordinaten +print "pick element ", co +el = root +for n in co: + el = el._data[n] + +el.show(True) # gewähltes Element anzeigen + +# funktioniert! + + + + -- cgit v0.9.1