本文整理汇总了Python中display.Display.register方法的典型用法代码示例。如果您正苦于以下问题:Python Display.register方法的具体用法?Python Display.register怎么用?Python Display.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类display.Display
的用法示例。
在下文中一共展示了Display.register方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from display import Display [as 别名]
# 或者: from display.Display import register [as 别名]
class Session:
"""
for stand-alone usage by the ox-user.
?for collaborative sessions see CoSession
"""
print("DEL import Session")
def __init__(self, name, window):
self._name = name
self._dis = Display(window)
self._co = Coach()
self._co.register(self, self._dis)
self._dis.register(self, self._co)
self._co.create_exercises() #TODO.WN091101 replace by storing Exerc.s
self._calcs = None #pop !
def run(self):
"""as long as user does exercises"""
#print("in Session.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()