subiquity/subiquitycore/ui/frame.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
1.7 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 """
import logging
from urwid import Text
2023-07-25 21:26:25 +00:00
2019-09-25 01:25:43 +00:00
from subiquitycore.ui.anchors import Header
2018-06-21 21:38:18 +00:00
from subiquitycore.ui.container import ListBox, Pile, WidgetWrap
2017-09-28 13:28:21 +00:00
from subiquitycore.ui.utils import Color
log = logging.getLogger("subiquitycore.ui.frame")
class SubiquityCoreUI(WidgetWrap):
right_icon = Text("")
def __init__(self):
self.header = Header("", self.right_icon)
self.pile = Pile(
[
("pack", self.header),
ListBox([Text("")]),
]
)
2019-09-25 02:25:11 +00:00
self.pile.focus_position = 1
super().__init__(Color.body(self.pile))
def _assign_contents(self, i, w):
self.pile.contents[i] = (w, self.pile.contents[i][1])
2018-05-18 04:27:05 +00:00
def set_header(self, title=None):
self._assign_contents(0, Header(title, self.right_icon))
2018-05-18 04:27:05 +00:00
@property
def body(self):
return self.pile.contents[1][0]
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._assign_contents(1, widget)