1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
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