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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# -*- coding: utf-8 -*-
import gtk
import pygtk
import pango
import random
import copy
from sugar.graphics import style
from settings import Settings
from coach import Coach
class Collection:
def __init__(self, display, coach):
self._sett = Settings()
# these data should come from pickle (see code in Settings)
self._data = [self._sett.get_setting('addsub_simp'),
self._sett.get_setting('passten'),
self._sett.get_setting('times_div')]
self._display = display
self._coach = coach
self._active_topic = None
def define_coll_gui(self):
""" Define gui-elements for presenting the collcetion. """
#WN.LV diesen Code ersetzen !!!!!
self.topic_box = gtk.HBox(True, 0)
self._display.topic_table.attach(self.topic_box, 0, 6, 0, 1)
def set_coll_gui(self):
""" Set gui-elements according to Collection.data. """
#WN.LV diesen Code ersetzen !!!!!
_i = 0
for _t in ['addsub_simp','passten','times_div']:
_i = _i + 1
self.button = gtk.Button()
self.image = gtk.Image()
if(_t == 'addsub_simp'):
self.image.set_from_file("img/addsub_simp.jpg")
elif(_t == 'passten'):
self.image.set_from_file("img/passten.jpg")
elif(_t == 'times_div'):
self.image.set_from_file("img/times_div.jpg")
self.button.set_image(self.image)
self.button.connect("clicked", self.topic_select_callback, _t)
self.topic_box.pack_start(self.button)
self.button.show()
self.topic_box.show()
def topic_select_callback(self, widget, topic):
"""callback: get the users choice from buttons above the settings"""
if(self._active_topic == None):
self._active_topic = topic
print('in collection.topic_select_callback, 422 self._sett=',
self._sett)
self._coach.notify(('new-topic', topic))
elif(self._active_topic == topic):
pass
elif(self._active_topic != topic):
self._active_topic = topic
#WN.LV the code below should go into display
self._display.settings_table.destroy()
self._display.settings_table = gtk.Table(15, 6, True)
self._display.table.attach(self._display.
settings_table, 1, 2, 0, 5)
self._display.settings_table.show()
self._display.table_with_start.destroy()
self._display.table_with_start = gtk.Table(15, 6, True)
self._display.table.attach(self._display.
table_with_start, 1, 2, 0, 5)
self._display.table_with_start.show()
self._coach.notify(('new-topic', topic))
|