2015-06-09 03:40:41 +00:00
|
|
|
# Copyright 2015 Canonical, Ltd.
|
2015-06-10 20:59:55 +00:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2015-06-09 03:40:41 +00:00
|
|
|
|
|
|
|
""" Base Frame Widget """
|
|
|
|
|
2015-07-23 02:31:21 +00:00
|
|
|
from urwid import Frame, WidgetWrap
|
2016-06-30 18:17:01 +00:00
|
|
|
from subiquitycore.ui.anchors import Header, Footer, Body
|
2015-06-23 20:29:08 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
|
2016-06-30 18:17:01 +00:00
|
|
|
log = logging.getLogger('subiquitycore.ui.frame')
|
2015-06-09 03:40:41 +00:00
|
|
|
|
|
|
|
|
2015-06-23 16:40:10 +00:00
|
|
|
class SubiquityUI(WidgetWrap):
|
2015-07-01 21:23:11 +00:00
|
|
|
|
2015-06-23 20:29:08 +00:00
|
|
|
def __init__(self, header=None, body=None, footer=None):
|
|
|
|
self.header = header if header else Header()
|
|
|
|
self.body = body if body else Body()
|
|
|
|
self.footer = footer if footer else Footer()
|
|
|
|
self.frame = Frame(self.body, header=self.header, footer=self.footer)
|
|
|
|
super().__init__(self.frame)
|
|
|
|
|
2015-07-01 21:23:11 +00:00
|
|
|
def keypress(self, size, key):
|
|
|
|
return super().keypress(size, key)
|
|
|
|
|
2015-07-03 00:51:32 +00:00
|
|
|
def set_header(self, title=None, excerpt=None):
|
2015-06-23 20:29:08 +00:00
|
|
|
self.frame.header = Header(title, excerpt)
|
|
|
|
|
2015-08-31 15:55:46 +00:00
|
|
|
def set_footer(self, message, completion=0):
|
|
|
|
self.frame.footer = Footer(message, completion)
|
2015-06-23 20:29:08 +00:00
|
|
|
|
|
|
|
def set_body(self, widget):
|
|
|
|
self.frame.body = widget
|