Package libxyz :: Package ui :: Module box_message |
[hide private]
[frames] | no frames]

# Source Code for Module libxyz.ui.box_message

     1  #-*- coding: utf8 -*
     2  #
     3  # Max E. Kuznecov ~syhpoon <syhpoon@syhpoon.name> 2008
     4  #
     5  # This file is part of XYZCommander.
     6  # XYZCommander is free software: you can redistribute it and/or modify
     7  # it under the terms of the GNU Lesser Public License as published by
     8  # the Free Software Foundation, either version 3 of the License, or
     9  # (at your option) any later version.
    10  # XYZCommander is distributed in the hope that it will be useful,
    11  # but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    13  # GNU Lesser Public License for more details.
    14  # You should have received a copy of the GNU Lesser Public License
    15  # along with XYZCommander. If not, see <http://www.gnu.org/licenses/>.
    16
    17  from libxyz.ui import lowui
    18  from libxyz.ui import align
    19  from libxyz.ui import Box
    20  from libxyz.ui import Border
    21
    22  import libxyz.ui
    23
    24 -class MessageBox(Box):
    25      """
    26      Simple box is used to display any kind of text messages
    27      Show the message until any key pressed
    28      """
    29
    30      resolution = (u"message_box", u"box", u"widget")
    31
    32 -    def __init__(self, xyz, body, message, title="", width=60):
    33          """
    34          @param xyz: XYZ data
    35          @param body: Top-level widget
    36          @param message: Message to display
    37          @param title: Box title
    38          @param width: Box width (including mount box)
    39
    40          Required resources: title, box, border, mount
    41          """
    42
    43          super(MessageBox, self).__init__(xyz, body, message, title, width)
    44          self.calc_size(5)
    45
    46          _title = self._strip_title(title.replace(u"\n", u" "))
    47
    48          if _title:
    49              _title_attr = self._attr(u"title")
    50          else:
    51              _title, _title_attr = None, None
    52
    53          _mount = lowui.AttrWrap(lowui.Filler(lowui.Text(u"")),
    54                                  self._attr(u"mount"))
    55
    56          _text = lowui.Text(message, align.CENTER)
    57          _box = lowui.Filler(_text)
    58          _box = Border(_box, _title, _title_attr, self._attr(u"border"))
    59          _box = lowui.AttrWrap(_box, self._attr(u"box"))
    60
    61          _mount = lowui.Overlay(_mount, body, align.CENTER, self.full_width,
    62                               align.MIDDLE, self.full_height)
    63
    64          _box = lowui.Overlay(_box, _mount, align.CENTER, self.box_width,
    65                               align.MIDDLE, self.box_height)
    66
    67          self.parent_init(_box)
    68