Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/ReckonPrimer.activity/session.py
blob: bb6f07328f235d4673a3f306eb67d0ed92cb45d0 (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
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
# -*- coding: utf-8 -*-

from author import Author
from coach import Coach
from collection import Collection
from display import Display
from learner import Learner

class Session:
    """
    for stand-alone usage by the ox-user.
    ?for collaborative sessions see CoSession
    """
    print("in session.py, after class Session")
            
    def __init__(self, name, window):
        self._name = name
        self._dis = Display(window)
        self._co = Coach()
        self._learner = Learner(self._dis, self._co)
        self._author = Author()
        self._collect = Collection(self._dis, self._co)
        self._co.register(self, self._dis, self._collect, self._learner)
        self._dis.register(self, self._co, self._learner)
        #self._co.create_exercises() #TODO.WN091101 replace by storing Exerc.s
        self._calcs = None #pop !

    def run(self):
        """
        Start execution of RP.
        Execution of RP is terminated by the user going bach to the OS.
        """
        #print("in Session.run")
        if False: # TODO choice according to menu CM
            pass # start Author
        else:
            self._learner.run()
            #self._co.request_exercise()
            #self._dis.init_calc() #TODOWN091101 take Exercise as argument
        
#    def notify(self, (msg, data)):
#        '''called by the observed objects'''
#        #print('in Session.notify: msg=,data=', msg, data)
#        if msg == 'setting-done': # from Coach
#            self._ex = data
#            self._calcs = data._generate_calcs()
#            self._key = data.get_topic()
#            (self._calcs).reverse()
#            _calc = (self._calcs).pop()
#            #print('in Session.notify: calc=', _calc)
#            _lines, self._input = data.format(_calc)
#            self._dis.display_calc(_lines)
#            self._curr_in = self._input.pop() #need _curr_in in notify
#            self._dis.create_entryline(self._curr_in)
#            # create_entryline sets the callback from gtk to Display
#        if msg == 'digit-done': # from Display
#            #print('in Session.notify, digit-done: _input=', self._input)
#            (lino, pos, dig, proterr, protok, li) = self._curr_in
#            self._dis.create_entryline((lino, -1, dig, proterr, protok, li))
#            if len(self._input) > 0:
#                self._curr_in = self._input.pop()
#                self._dis.create_entryline(self._curr_in)
#            else: # start new calc
#                self._dis.show_progress()
#                if len(self._calcs) > 0:
#                    _calc = (self._calcs).pop()
#                    print('in Session.notify: calc=', _calc)
#                    _lines, self._input = self._ex.format(_calc)
#                    self._dis.display_calc(_lines)
#                    self._curr_in = self._input.pop() #need _curr_in in notify
#                    self._dis.create_entryline(self._curr_in)
#                    # create_entryline sets the callback from gtk to Display
#                else:
#                    self._dis.finish_calc()