object.old_menu = appuifw.app.menu
object.old_exit_key_handler = appuifw.app.exit_key_handler
object.old_title=appuifw.app.title
- object.lock = Ao_lock()
def restore_gui(object):
appuifw.app.body = object.old_gui
appuifw.app.exit_key_handler = object.old_exit_key_handler
appuifw.app.title = object.old_title
-
-class ListView(object):
+class View(object):
def __init__(self):
- self.view = appuifw.Listbox(self.items(),self.change_entry)
- super(ListView, self).__init__()
+ self.title = None
+ self.view = None
+ self.lock = Ao_lock()
+ self.exit_flag = False
+ super(View, self).__init__()
def set_title(self, title):
self.title = title
-
- def change_entry(self):
- pass
-
+
+ def set_view(self, view):
+ """
+ Sets the main view to be displayed (e.g., an appuifw.Listbox
+ instance).
+ """
+ self.view = view
+
def run(self):
self.adjustment = None
- appuifw.app.screen=COMMON_CONFIG['screen'].encode('utf-8')
save_gui(self)
+ appuifw.app.screen=COMMON_CONFIG['screen'].encode('utf-8')
appuifw.app.title=self.title
appuifw.app.body=self.view
appuifw.app.exit_key_handler=self.exit
except:
pass
restore_gui(self)
+
def exit(self):
self.exit_flag = True
self.lock.signal()
+ super(View, self).exit()
+
+ def refresh(self):
+ """
+ Update the gui after a change in model or some user interaction.
+ Should be filled by subclasses.
+ """
+ super(View, self).refresh()
+
+class ListView(View):
+ def __init__(self):
+ super(ListView, self).__init__()
+ self.set_view(appuifw.Listbox(self.items(),self.change_entry))
+ def change_entry(self):
+ pass
+
def update(self,subject=None):
#logger.log(u'Updated %s'%repr(self))
if self.lock:
def __init__(self):
self.widgets = self.generate_widgets()
super(WidgetBasedListView,self).__init__()
- self.exit_flag = False
def run(self):
self.refresh()