subiquity/subiquitycore/ui/frame.py

58 lines
1.8 KiB
Python
Raw Normal View History

# Copyright 2015 Canonical, Ltd.
#
# 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/>.
""" Base Frame Widget """
from urwid import (
Frame,
Text,
WidgetWrap,
)
from subiquitycore.ui.anchors import Header, Footer
from subiquitycore.ui.container import ListBox
2017-09-28 13:28:21 +00:00
from subiquitycore.ui.utils import Color
import logging
log = logging.getLogger('subiquitycore.ui.frame')
class SubiquityUI(WidgetWrap):
def __init__(self):
2018-05-18 04:27:05 +00:00
self.header = Header("")
self.footer = Footer("", 0, 1)
2018-05-24 22:43:55 +00:00
self.frame = Frame(
ListBox([Text("")]),
header=self.header, footer=self.footer)
self.progress_current = 0
self.progress_completion = 0
2017-09-28 13:28:21 +00:00
super().__init__(Color.body(self.frame))
def keypress(self, size, key):
return super().keypress(size, key)
2018-05-18 04:27:05 +00:00
def set_header(self, title=None):
self.frame.header = Header(title)
def set_footer(self, message):
self.frame.footer = Footer(message, self.progress_current,
self.progress_completion)
2018-05-18 04:27:05 +00:00
def set_body(self, widget):
2018-05-18 04:27:05 +00:00
self.set_header(_(widget.title))
self.frame.body = widget
2018-05-18 04:27:05 +00:00
self.set_footer(_(widget.footer))