Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/ReckonPrimer.activity/exercises/exaddsimp.py
blob: d4dc22222dc5cf1230af0214d6f77df3cf715f05 (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
# -*- coding: utf-8 -*-
#(c) Julia Schönhart
#(c) Daniela Zierler

import gtk
import pygtk
import pango
import random
import copy
from sugar.graphics import style

from exercise import Exercise
from functions import *

class ExAddSimp(Exercise):
    def __init__(self, dis, (sett, errors)):
        self._display = dis
        self._sett = sett
        self._errors = errors
#        {'topic'  : 'addsub_simp',
#         'title' : 'template exaddsimp',
#         'descript': 'addition and subtraction without carry, \
#                            i.e. without passing the 10 barrier. ',
#         'icon' : None,     # for quick reference of the exercise      
#         'calclines': 1,    # no. of lines for calc to be input.
#         'MAX'    : 30,     # maximum of calcs generated.
#                            # Generate fills up by varying input.
#         'MIN'    : 20,     # minimum of calcs generated UNUSED
#         'min'    : 0,      # minimum in size of a number in a calc
#         'max'    : 1,      # maximum  in size of a number in a calc
#                            # 0 <= min <= max <= 10
#         '+'      : True,   # make all additions min..max
#         '-'      : True,   # make all subtactions min..max
#         '_+_=_'  : True,   # = is _right_ from operator, e.g. 1+2=3
#         'input=' : [1,3,5],# list of positions in calc: 1 | 3 | 5
#                            # where input is possible;
#                            # actual positions chosen by Generate.
#         '_=_+_'  : False,  # = is _left_ from operator, e.g. 3=1+2
#         '=input' : [1,3,5],# analogous to '_+_=_'
#         'shuffle': True,   # shuffle _all_ the calcs
#         'cut-max': True    # cut set of all calcs down to MAX
#        }
        self._calcs = self._generate_calcs()

    def _generate_calcs(self):
        _dic = self._sett
        _calcs = []
        if _dic['+']: # '+' or '-' are True
            _c = self._alladd(_dic['min'], _dic['max'])
            if _dic['_+_=_']: # '_+_=_' or '_=_+_' are True
                # choose 1 actual position for input
                _cc = [(c, random.choice(_dic['input='])) for c in _c]
                _calcs.extend(_cc)
            if _dic['_=_+_']:
                _cc = [swap_eq(c) for c in _c]
                # choose 1 actual position for input
                _cc = [(c, random.choice(_dic['=input'])) for c in _cc]
                _calcs.extend(_cc)
        if _dic['-']:
            _c = self._allsub(_dic['min'], _dic['max'])
            if _dic['_+_=_']:
                _cc = [(c, random.choice(_dic['input='])) for c in _c]
                _calcs.extend(_cc)
            if _dic['_=_+_']:
                _cc = [swap_eq(c) for c in _c]
                _cc = [(c, random.choice(_dic['=input'])) for c in _cc]
                _calcs.extend(_cc)
        #if len(_calcs) < _dic['MIN']: TODO
        if _dic['shuffle']:
            random.shuffle(_calcs)
        if _dic['cut-max']:
            _c = copy.deepcopy(_calcs)  # make a copy
            _calcs = _c[:_dic['MAX']]
        #print('in Generate.addsub_simp calcs=', _calcs)
        return _calcs

    def format(self, (calc, linepos)):
        """format the calc for display, prepare overlays for input"""
        #@print('in Display.format_addsub_simp: calc=', (calc, linepos))#@
        _ccs = collect_digits(calc)
        #print('in Display.format_addsub_simp: _ccs=',_ccs )
        _l0 = make_line(_ccs, linepos)
        _ip = make_input(_ccs, linepos)
        #@print('in Display.format_addsub_simp: return=', ([_l0], _ip)) #@
        return ([_l0], _ip)
        #return ([[' ', '1', '0', ' ', '-', ' ', '7', ' ', '=', ' ', '_', ' ']],
        #[(0, 10, '3', ' 10 - 7 = _ ', ' 10 - 7 = 3 ',
        #[' ', '1', '0', ' ', '-', ' ', '7', ' ', '=', ' ', '3', ' '])])

    def define_buttons(self):
        """ See comment in exercise.define_buttons. """

        #print('in exaddsimp.define_buttons, self._sett=', self._sett)
        #self.label_count = gtk.Label(str(self.count()))
        #self.label6.modify_font(pango.FontDescription("sans 12"))
        #self._display.settings_table.attach(self.label6, 0, 1, 1, 2 ) 
        #self.label6.show()
        
        self.label_to = gtk.Label('-->')
        self.label_to.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label_to, 1, 2, 1, 2 ) 
        self.label_to.show()
        
        self.toggle_max = gtk.ToggleButton(str(self._display._sett['MAX']))
        self.toggle_label = self.toggle_max.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_max.connect("toggled", self.toggle_max_callback)
        self._display.settings_table.attach(self.toggle_max, 2, 3, 1, 2)
        self.toggle_max.show()
        
        self.toggle_shuffle = gtk.ToggleButton("@")
        self.toggle_label = self.toggle_shuffle.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_shuffle.connect("toggled", self.toggle_shuffle_callback)
        self._display.settings_table.attach(self.toggle_shuffle, 5, 6, 13, 14 )
        self.toggle_shuffle.show()

        self.toggle_equal_fixed_right = gtk.ToggleButton("<<")
        self.toggle_label = self.toggle_equal_fixed_right.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_equal_fixed_right.connect("toggled", self.toggle_equal_fixed_right_callback)
        self._display.settings_table.attach(self.toggle_equal_fixed_right, 5, 6, 10, 11 )
        self.toggle_equal_fixed_right.show()

        self.toggle_equal_fixed_left = gtk.ToggleButton("<<")
        self.toggle_label = self.toggle_equal_fixed_left.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_equal_fixed_left.connect("toggled", self.toggle_equal_fixed_left_callback)
        self._display.settings_table.attach(self.toggle_equal_fixed_left, 5, 6, 12, 13 )
        self.toggle_equal_fixed_left.show()

        self.toggle_pos1 = gtk.ToggleButton("--")
        self.toggle_label = self.toggle_pos1.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_pos1.connect("toggled", self.toggle_pos1_callback)
        self._display.settings_table.attach(self.toggle_pos1, 0, 1, 11, 12 )
        self.toggle_pos1.show()

        self.toggle_pos3 = gtk.ToggleButton("--")
        self.toggle_label = self.toggle_pos3.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_pos3.connect("toggled", self.toggle_pos3_callback)
        self._display.settings_table.attach(self.toggle_pos3, 2, 3, 11, 12 )
        self.toggle_pos3.show()

        self.toggle_pos5 = gtk.ToggleButton("--")
        self.toggle_label = self.toggle_pos5.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_pos5.connect("toggled", self.toggle_pos5_callback)
        self._display.settings_table.attach(self.toggle_pos5, 4, 5, 11, 12 )
        self.toggle_pos5.show()

        self.toggle_pos1_lower = gtk.ToggleButton("--")
        self.toggle_label = self.toggle_pos1_lower.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_pos1_lower.connect("toggled", self.toggle_pos1_lower_callback)
        self._display.settings_table.attach(self.toggle_pos1_lower, 0, 1, 13, 14 )
        self.toggle_pos1_lower.show()

        self.toggle_pos3_lower = gtk.ToggleButton("--")
        self.toggle_label = self.toggle_pos3_lower.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_pos3_lower.connect("toggled", self.toggle_pos3_lower_callback)
        self._display.settings_table.attach(self.toggle_pos3_lower, 2, 3, 13, 14 )
        self.toggle_pos3_lower.show()

        self.toggle_pos5_lower = gtk.ToggleButton("--")
        self.toggle_label = self.toggle_pos5_lower.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_pos5_lower.connect("toggled", self.toggle_pos5_lower_callback)
        self._display.settings_table.attach(self.toggle_pos5_lower, 4, 5, 13, 14 )
        self.toggle_pos5_lower.show()

        self.label0 = gtk.Label("0")
        self.label0.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label0, 0, 1, 10, 11 )
        self.label0.show()

        self.toggle_plus = gtk.ToggleButton("+")
        self.toggle_label = self.toggle_plus.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_plus.connect("toggled", self.toggle_plus_callback)
        self._display.settings_table.attach(self.toggle_plus, 1, 2, 10, 11 )
        self.toggle_plus.show()

        self.toggle_minus = gtk.ToggleButton("-")
        self.toggle_label = self.toggle_minus.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_minus.connect("toggled", self.toggle_minus_callback)
        self._display.settings_table.attach(self.toggle_minus, 1, 2, 9, 10 )
        self.toggle_minus.show()

        self.label02 = gtk.Label("0")
        self.label02.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label02, 2, 3, 10, 11 )
        self.label02.show()

        self.label_equal = gtk.Label("=")
        self.label_equal.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label_equal, 3, 4, 10, 11 )
        self.label_equal.show()

        self.label0_lower = gtk.Label("0")
        self.label0_lower.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label0_lower, 0, 1, 12, 13 )
        self.label0_lower.show()

        self.label_equal_lower = gtk.Label("=")
        self.label_equal_lower.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label_equal_lower, 1, 2, 12, 13 )
        self.label_equal_lower.show()

        self.label02_lower = gtk.Label("0")
        self.label02_lower.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label02_lower, 2, 3, 12, 13 )
        self.label02_lower.show()

        self.label_plus_minus_lower = gtk.Label("+")
        self.label_plus_minus_lower.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label_plus_minus_lower, 3, 4, 12, 13 )
        self.label_plus_minus_lower.show()

        self.label03_lower = gtk.Label("0")
        self.label03_lower.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label03_lower, 4, 5, 12, 13 )
        self.label03_lower.show()

        # Buttons 9 .. 0
        self.number_butts = []
        for i in range(0,9+1):
            self.toggle = gtk.ToggleButton(str(i))
            self.toggle_label = self.toggle.get_child()
            self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
            self.toggle.connect("toggled", self.toggle_number_callback, i)
            self._display.settings_table.attach(self.toggle, 4, 5, 10-i, 11-i)
            self.toggle.show()
            self.number_butts.append(self.toggle)

    def set_buttons(self, sett):

        for i in range(sett['min'],sett['max']+1):
            self.number_butts[i].set_active(True)

        if ( sett['+'] == True ):
            self.toggle_plus.set_active(True)
        else:
            self.toggle_plus.set_active(False)

        if ( sett['-'] == True ):
            self.toggle_minus.set_active(True)
        else:
            self.toggle_minus.set_active(False)

        if ( sett['shuffle'] == True ):
            self.toggle_shuffle.set_active(True)
        else:
            self.toggle_shuffle.set_active(False)

        if ( sett['_+_=_'] == True ):
            self.toggle_equal_fixed_right.set_active(True)
        else:
            self.toggle_equal_fixed_right.set_active(False)

        if ( sett['_=_+_'] == True ):
            self.toggle_equal_fixed_left.set_active(True)
        else:
            self.toggle_equal_fixed_left.set_active(False)

        for i in sett['input=']:
            if( i == 1 ):
                self.toggle_pos1.set_active(True)
            if ( i == 3 ):
                self.toggle_pos3.set_active(True)
            if ( i == 5 ):
                self.toggle_pos5.set_active(True)

        for i in sett['=input']:
            if( i == 1 ):
                self.toggle_pos1_lower.set_active(True)
            if ( i == 3 ):
                self.toggle_pos3_lower.set_active(True)
            if ( i == 5 ):
                self.toggle_pos5_lower.set_active(True)

    #**** callbacks ********************************************************

    def toggle_number_callback(self, widget, i):

        if widget.get_active():
            if(i < self._display._sett['min']):
                self._display._sett['min'] = i
                self.set_buttons(self._display._sett)
            elif( i > self._display._sett['max'] ):
                self._display._sett['max'] = i
                self.set_buttons(self._display._sett)

        else:
            if( i == self._display._sett['min'] ):
                if( self._display._sett['min'] == self._display._sett['max'] ):
                    widget.set_active(True)
                else:
                    self._display._sett['min'] = i+1
                self.set_buttons(self._display._sett)

            elif( i == self._display._sett['max'] ):
                if( self._display._sett['min'] == self._display._sett['max'] ):
                    widget.set_active(True)
                else:
                    self._display._sett['max'] = i-1
                self.set_buttons(self._display._sett)

            else:
                widget.set_active(True)
        #BEGIN LPCHANGE
        self._display_generated_calcs('digit '+ str(i))
        #END LPCHANGE 
        
    # callbacks updating the settings
    def toggle_max_callback(self, widget):
        if widget.get_active():
            self._display._sett['cut-max'] = True
            #BEGIN LPCHANGE
            self._display_generated_calcs('max')
            #END LPCHANGE  
        else:
            self._display._sett['cut-max'] = False
            #BEGIN LPCHANGE
            self._display_generated_calcs('no max')
            #END LPCHANGE             
            
    def toggle_plus_callback(self, widget):
        if widget.get_active():
            self._display._sett['+'] = True
            #BEGIN LPCHANGE
            self._display_generated_calcs('plus')
            #END LPCHANGE    
        else:
            if( self.toggle_minus.get_active() ):
                self._display._sett['+'] = False
                #BEGIN LPCHANGE
                self._display_generated_calcs('no plus')
                #END LPCHANGE                 

            else:
                widget.set_active(True)
            

    def toggle_minus_callback(self, widget):
        if widget.get_active():
            self._display._sett['-'] = True
            #BEGIN LPCHANGE
            self._display_generated_calcs('minus')
            #END LPCHANGE 
        else:
            if( self.toggle_plus.get_active() ):
                self._display._sett['-'] = False
                #BEGIN LPCHANGE
                self._display_generated_calcs('no minus')
                #END LPCHANGE 
            else:
               widget.set_active(True)
               

    def toggle_shuffle_callback(self, widget):
        if widget.get_active():
            self._display._sett['shuffle'] = True
        else:
            self._display._sett['shuffle'] = False
                      

    def toggle_equal_fixed_right_callback(self, widget):
        if widget.get_active():
            self._display._sett['_+_=_'] = True
            self.toggle_pos1.set_active(True)
            self.toggle_pos3.set_active(True)
            self.toggle_pos5.set_active(True)
            #BEGIN LPCHANGE
            self._display_generated_calcs('fixed right')
            #END LPCHANGE 
        else:
            if( self.toggle_equal_fixed_left.get_active() ):
                self._display._sett['_+_=_'] = False
                self.toggle_pos1.set_active(False)
                self.toggle_pos3.set_active(False)
                self.toggle_pos5.set_active(False)
                #BEGIN LPCHANGE
                self._display_generated_calcs('unfixed right')
                #END LPCHANGE 
            else:
                widget.set_active(True)
                

    def toggle_equal_fixed_left_callback(self, widget):
        if widget.get_active():
            self._display._sett['_=_+_'] = True
            self.toggle_pos1_lower.set_active(True)
            self.toggle_pos3_lower.set_active(True)
            self.toggle_pos5_lower.set_active(True)
            #BEGIN LPCHANGE
            self._display_generated_calcs('fixed left')
            #END LPCHANGE                 
        else:
            if( self.toggle_equal_fixed_right.get_active() ):
                self._display._sett['_=_+_'] = False
                self.toggle_pos1_lower.set_active(False)
                self.toggle_pos3_lower.set_active(False)
                self.toggle_pos5_lower.set_active(False)
                #BEGIN LPCHANGE
                self._display_generated_calcs('unfixed left')
                #END LPCHANGE  
            else:
                widget.set_active(True)
               

    def toggle_pos1_callback(self, widget):

        if( self.toggle_equal_fixed_right.get_active() ):
            pass
        else:
            self.toggle_pos1.set_active(False)

        if( self.toggle_pos1.get_active() ):
            self._display._sett['input='] = list(set(self._display._sett['input=']) | set([1]))
        else:
            if( self.toggle_equal_fixed_right.get_active() ):
                if( not self.toggle_pos3.get_active() and not self.toggle_pos5.get_active() ):
                    self.toggle_pos1.set_active(True)
                else:
                    self._display._sett['input='] = list(set(self._display._sett['input=']) - set([1]))

    def toggle_pos3_callback(self, widget):
        if( self.toggle_equal_fixed_right.get_active() ):
            pass
        else:
            self.toggle_pos3.set_active(False)

        if( self.toggle_pos3.get_active() ):
            self._display._sett['input='] = list(set(self._display._sett['input=']) | set([3]))
        else:
            if( self.toggle_equal_fixed_right.get_active() ):
                if( not self.toggle_pos1.get_active() and not self.toggle_pos5.get_active() ):
                    self.toggle_pos3.set_active(True)
                else:
                    self._display._sett['input='] = list(set(self._display._sett['input=']) - set([3]))

    def toggle_pos5_callback(self, widget):
        if( self.toggle_equal_fixed_right.get_active() ):
            pass
        else:
            self.toggle_pos5.set_active(False)

        if( self.toggle_pos5.get_active() ):
            self._display._sett['input='] = list(set(self._display._sett['input=']) | set([5]))
        else:
            if( self.toggle_equal_fixed_right.get_active() ):
                if( not self.toggle_pos1.get_active() and not self.toggle_pos3.get_active() ):
                    self.toggle_pos5.set_active(True)
                else:
                    self._display._sett['input='] = list(set(self._display._sett['input=']) - set([5]))

    def toggle_pos1_lower_callback(self, widget):

        if( self.toggle_equal_fixed_left.get_active() ):
            pass
        else:
            self.toggle_pos1_lower.set_active(False)

        if( self.toggle_pos1_lower.get_active() ):
            self._display._sett['=input'] = list(set(self._display._sett['=input']) | set([1]))
        else:
            if( self.toggle_equal_fixed_left.get_active() ):
                if( not self.toggle_pos3_lower.get_active() and not self.toggle_pos5_lower.get_active() ):
                    self.toggle_pos1_lower.set_active(True)
                else:
                    self._display._sett['=input'] = list(set(self._display._sett['=input']) - set([1]))

    def toggle_pos3_lower_callback(self, widget):
        if( self.toggle_equal_fixed_left.get_active() ):
            pass
        else:
            self.toggle_pos3_lower.set_active(False)

        if( self.toggle_pos3_lower.get_active() ):
            self._display._sett['=input'] = list(set(self._display._sett['=input']) | set([3]))
        else:
            if( self.toggle_equal_fixed_left.get_active() ):
                if( not self.toggle_pos1_lower.get_active() and not self.toggle_pos5_lower.get_active() ):
                    self.toggle_pos3_lower.set_active(True)
                else:
                    self._display._sett['=input'] = list(set(self._display._sett['=input']) - set([3]))

    def toggle_pos5_lower_callback(self, widget):
        if( self.toggle_equal_fixed_left.get_active() ):
            pass
        else:
            self.toggle_pos5_lower.set_active(False)

        if( self.toggle_pos5_lower.get_active() ):
            self._display._sett['=input'] = list(set(self._display._sett['=input']) | set([5]))
        else:
            if( self.toggle_equal_fixed_left.get_active() ):
                if( not self.toggle_pos1_lower.get_active() and not self.toggle_pos3_lower.get_active()):
                    self.toggle_pos5_lower.set_active(True)
                else:
                    self._display._sett['=input'] = list(set(self._display._sett['=input']) - set([5]))

    ##### end of public methods ############################################
    def _alladd(self, min, max):
        """generate all calcs for +"""
        _adds = []
        for _i in range(min, max +1):
            for _j in range(0, _i +1):
                #print("in Generate._alladd i= ",_i,"  j= ", _j)
                _c = [to_str_99(_j),'+',to_str_99(_i-_j),'=',to_str_99(_i)]
                _c = flatten(_c)
                _c = strip(_c, '#')
                _adds.append(_c)
                #print("in Generate._alladd adds= ", _adds)
        return _adds

    def _allsub(self, min, max):
        """generate all calcs for -"""
        _subs = []
        for _i in range(min, max +1):
            for _j in range(0, _i +1) :
                #print ("in Generate._allsub i= ",_i,"  j= ", _j)
                _c = [to_str_99(_i), '-', to_str_99(_j), '=', to_str_99(_i - _j)]
                _c = flatten(_c)
                _c = strip(_c, '#')
                _subs.append(_c)
        return _subs

#BEGIN LPCHANGE
    def _display_generated_calcs(self, change):
        print("DEBUG: in exaddsubsimp._display_generated_calcs()")
        self._display.protocol_generated_calcs(self._generate_calcs(), change)
#END LPCHANGE