urwid 2.6.0.post0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of urwid might be problematic. Click here for more details.
- urwid/__init__.py +333 -0
- urwid/canvas.py +1413 -0
- urwid/command_map.py +137 -0
- urwid/container.py +59 -0
- urwid/decoration.py +65 -0
- urwid/display/__init__.py +97 -0
- urwid/display/_posix_raw_display.py +413 -0
- urwid/display/_raw_display_base.py +914 -0
- urwid/display/_web.css +12 -0
- urwid/display/_web.js +462 -0
- urwid/display/_win32.py +171 -0
- urwid/display/_win32_raw_display.py +269 -0
- urwid/display/common.py +1219 -0
- urwid/display/curses.py +690 -0
- urwid/display/escape.py +624 -0
- urwid/display/html_fragment.py +251 -0
- urwid/display/lcd.py +518 -0
- urwid/display/raw.py +37 -0
- urwid/display/web.py +636 -0
- urwid/event_loop/__init__.py +55 -0
- urwid/event_loop/abstract_loop.py +175 -0
- urwid/event_loop/asyncio_loop.py +231 -0
- urwid/event_loop/glib_loop.py +294 -0
- urwid/event_loop/main_loop.py +721 -0
- urwid/event_loop/select_loop.py +230 -0
- urwid/event_loop/tornado_loop.py +206 -0
- urwid/event_loop/trio_loop.py +302 -0
- urwid/event_loop/twisted_loop.py +269 -0
- urwid/event_loop/zmq_loop.py +275 -0
- urwid/font.py +695 -0
- urwid/graphics.py +96 -0
- urwid/highlight.css +19 -0
- urwid/listbox.py +1899 -0
- urwid/monitored_list.py +522 -0
- urwid/numedit.py +376 -0
- urwid/signals.py +330 -0
- urwid/split_repr.py +130 -0
- urwid/str_util.py +358 -0
- urwid/text_layout.py +632 -0
- urwid/treetools.py +515 -0
- urwid/util.py +557 -0
- urwid/version.py +16 -0
- urwid/vterm.py +1806 -0
- urwid/widget/__init__.py +181 -0
- urwid/widget/attr_map.py +161 -0
- urwid/widget/attr_wrap.py +140 -0
- urwid/widget/bar_graph.py +649 -0
- urwid/widget/big_text.py +77 -0
- urwid/widget/box_adapter.py +126 -0
- urwid/widget/columns.py +1145 -0
- urwid/widget/constants.py +574 -0
- urwid/widget/container.py +227 -0
- urwid/widget/divider.py +110 -0
- urwid/widget/edit.py +718 -0
- urwid/widget/filler.py +403 -0
- urwid/widget/frame.py +539 -0
- urwid/widget/grid_flow.py +539 -0
- urwid/widget/line_box.py +194 -0
- urwid/widget/overlay.py +829 -0
- urwid/widget/padding.py +597 -0
- urwid/widget/pile.py +971 -0
- urwid/widget/popup.py +170 -0
- urwid/widget/progress_bar.py +141 -0
- urwid/widget/scrollable.py +597 -0
- urwid/widget/solid_fill.py +44 -0
- urwid/widget/text.py +354 -0
- urwid/widget/widget.py +852 -0
- urwid/widget/widget_decoration.py +166 -0
- urwid/widget/wimp.py +792 -0
- urwid/wimp.py +23 -0
- urwid-2.6.0.post0.dist-info/COPYING +504 -0
- urwid-2.6.0.post0.dist-info/METADATA +332 -0
- urwid-2.6.0.post0.dist-info/RECORD +75 -0
- urwid-2.6.0.post0.dist-info/WHEEL +5 -0
- urwid-2.6.0.post0.dist-info/top_level.txt +1 -0
urwid/widget/big_text.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from urwid.canvas import CanvasJoin, CompositeCanvas, TextCanvas
|
|
6
|
+
from urwid.util import decompose_tagmarkup
|
|
7
|
+
|
|
8
|
+
from .constants import Sizing
|
|
9
|
+
from .widget import Widget, fixed_size
|
|
10
|
+
|
|
11
|
+
if typing.TYPE_CHECKING:
|
|
12
|
+
from urwid import Font
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class BigText(Widget):
|
|
16
|
+
_sizing = frozenset([Sizing.FIXED])
|
|
17
|
+
|
|
18
|
+
def __init__(self, markup, font: Font) -> None:
|
|
19
|
+
"""
|
|
20
|
+
markup -- same as Text widget markup
|
|
21
|
+
font -- instance of a Font class
|
|
22
|
+
"""
|
|
23
|
+
super().__init__()
|
|
24
|
+
self.text: str = ""
|
|
25
|
+
self.attrib = []
|
|
26
|
+
self.font: Font = font
|
|
27
|
+
self.set_font(font)
|
|
28
|
+
self.set_text(markup)
|
|
29
|
+
|
|
30
|
+
def set_text(self, markup):
|
|
31
|
+
self.text, self.attrib = decompose_tagmarkup(markup)
|
|
32
|
+
self._invalidate()
|
|
33
|
+
|
|
34
|
+
def get_text(self):
|
|
35
|
+
"""
|
|
36
|
+
Returns (text, attributes).
|
|
37
|
+
"""
|
|
38
|
+
return self.text, self.attrib
|
|
39
|
+
|
|
40
|
+
def set_font(self, font: Font) -> None:
|
|
41
|
+
self.font = font
|
|
42
|
+
self._invalidate()
|
|
43
|
+
|
|
44
|
+
def pack(self, size: tuple[()] | None = None, focus: bool = False) -> tuple[int, int]:
|
|
45
|
+
rows = self.font.height
|
|
46
|
+
cols = 0
|
|
47
|
+
for c in self.text:
|
|
48
|
+
cols += self.font.char_width(c)
|
|
49
|
+
return cols, rows
|
|
50
|
+
|
|
51
|
+
def render(self, size: tuple[()], focus: bool = False) -> CompositeCanvas:
|
|
52
|
+
fixed_size(size) # complain if parameter is wrong
|
|
53
|
+
a = None
|
|
54
|
+
ai = ak = 0
|
|
55
|
+
o = []
|
|
56
|
+
rows = self.font.height
|
|
57
|
+
attrib = [*self.attrib, (None, len(self.text))]
|
|
58
|
+
for ch in self.text:
|
|
59
|
+
if not ak:
|
|
60
|
+
a, ak = attrib[ai]
|
|
61
|
+
ai += 1
|
|
62
|
+
ak -= 1
|
|
63
|
+
width = self.font.char_width(ch)
|
|
64
|
+
if not width:
|
|
65
|
+
# ignore invalid characters
|
|
66
|
+
continue
|
|
67
|
+
c = self.font.render(ch)
|
|
68
|
+
if a is not None:
|
|
69
|
+
c = CompositeCanvas(c)
|
|
70
|
+
c.fill_attr(a)
|
|
71
|
+
o.append((c, None, False, width))
|
|
72
|
+
if o:
|
|
73
|
+
canv = CanvasJoin(o)
|
|
74
|
+
else:
|
|
75
|
+
canv = CompositeCanvas(TextCanvas([b""] * rows, maxcol=0, check_width=False))
|
|
76
|
+
canv.set_depends([])
|
|
77
|
+
return canv
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
import warnings
|
|
5
|
+
|
|
6
|
+
from urwid.canvas import CompositeCanvas
|
|
7
|
+
|
|
8
|
+
from .constants import Sizing
|
|
9
|
+
from .widget_decoration import WidgetDecoration, WidgetError
|
|
10
|
+
|
|
11
|
+
WrappedWidget = typing.TypeVar("WrappedWidget")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class BoxAdapterError(WidgetError):
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class BoxAdapter(WidgetDecoration[WrappedWidget]):
|
|
19
|
+
"""
|
|
20
|
+
Adapter for using a box widget where a flow widget would usually go
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
no_cache: typing.ClassVar[list[str]] = ["rows"]
|
|
24
|
+
|
|
25
|
+
def __init__(self, box_widget: WrappedWidget, height: int) -> None:
|
|
26
|
+
"""
|
|
27
|
+
Create a flow widget that contains a box widget
|
|
28
|
+
|
|
29
|
+
:param box_widget: box widget to wrap
|
|
30
|
+
:type box_widget: Widget
|
|
31
|
+
:param height: number of rows for box widget
|
|
32
|
+
:type height: int
|
|
33
|
+
|
|
34
|
+
>>> from urwid import SolidFill
|
|
35
|
+
>>> BoxAdapter(SolidFill(u"x"), 5) # 5-rows of x's
|
|
36
|
+
<BoxAdapter flow widget <SolidFill box widget 'x'> height=5>
|
|
37
|
+
"""
|
|
38
|
+
if hasattr(box_widget, "sizing") and Sizing.BOX not in box_widget.sizing():
|
|
39
|
+
raise BoxAdapterError(f"{box_widget!r} is not a box widget")
|
|
40
|
+
super().__init__(box_widget)
|
|
41
|
+
|
|
42
|
+
self.height = height
|
|
43
|
+
|
|
44
|
+
def _repr_attrs(self) -> dict[str, typing.Any]:
|
|
45
|
+
return {**super()._repr_attrs(), "height": self.height}
|
|
46
|
+
|
|
47
|
+
# originally stored as box_widget, keep for compatibility
|
|
48
|
+
@property
|
|
49
|
+
def box_widget(self) -> WrappedWidget:
|
|
50
|
+
warnings.warn(
|
|
51
|
+
"original stored as original_widget, keep for compatibility",
|
|
52
|
+
PendingDeprecationWarning,
|
|
53
|
+
stacklevel=2,
|
|
54
|
+
)
|
|
55
|
+
return self.original_widget
|
|
56
|
+
|
|
57
|
+
@box_widget.setter
|
|
58
|
+
def box_widget(self, widget: WrappedWidget) -> None:
|
|
59
|
+
warnings.warn(
|
|
60
|
+
"original stored as original_widget, keep for compatibility",
|
|
61
|
+
PendingDeprecationWarning,
|
|
62
|
+
stacklevel=2,
|
|
63
|
+
)
|
|
64
|
+
self.original_widget = widget
|
|
65
|
+
|
|
66
|
+
def sizing(self) -> frozenset[Sizing]:
|
|
67
|
+
return frozenset((Sizing.FLOW,))
|
|
68
|
+
|
|
69
|
+
def rows(self, size: tuple[int], focus: bool = False) -> int:
|
|
70
|
+
"""
|
|
71
|
+
Return the predetermined height (behave like a flow widget)
|
|
72
|
+
|
|
73
|
+
>>> from urwid import SolidFill
|
|
74
|
+
>>> BoxAdapter(SolidFill(u"x"), 5).rows((20,))
|
|
75
|
+
5
|
|
76
|
+
"""
|
|
77
|
+
return self.height
|
|
78
|
+
|
|
79
|
+
# The next few functions simply tack-on our height and pass through
|
|
80
|
+
# to self._original_widget
|
|
81
|
+
def get_cursor_coords(self, size: tuple[int]) -> int | None:
|
|
82
|
+
(maxcol,) = size
|
|
83
|
+
if not hasattr(self._original_widget, "get_cursor_coords"):
|
|
84
|
+
return None
|
|
85
|
+
return self._original_widget.get_cursor_coords((maxcol, self.height))
|
|
86
|
+
|
|
87
|
+
def get_pref_col(self, size: tuple[int]) -> int | None:
|
|
88
|
+
(maxcol,) = size
|
|
89
|
+
if not hasattr(self._original_widget, "get_pref_col"):
|
|
90
|
+
return None
|
|
91
|
+
return self._original_widget.get_pref_col((maxcol, self.height))
|
|
92
|
+
|
|
93
|
+
def keypress(self, size: tuple[int], key: str) -> str | None:
|
|
94
|
+
(maxcol,) = size
|
|
95
|
+
return self._original_widget.keypress((maxcol, self.height), key)
|
|
96
|
+
|
|
97
|
+
def move_cursor_to_coords(self, size: tuple[int], col: int, row: int):
|
|
98
|
+
(maxcol,) = size
|
|
99
|
+
if not hasattr(self._original_widget, "move_cursor_to_coords"):
|
|
100
|
+
return True
|
|
101
|
+
return self._original_widget.move_cursor_to_coords((maxcol, self.height), col, row)
|
|
102
|
+
|
|
103
|
+
def mouse_event(
|
|
104
|
+
self,
|
|
105
|
+
size: tuple[int],
|
|
106
|
+
event: str,
|
|
107
|
+
button: int,
|
|
108
|
+
col: int,
|
|
109
|
+
row: int,
|
|
110
|
+
focus: bool,
|
|
111
|
+
) -> bool | None:
|
|
112
|
+
(maxcol,) = size
|
|
113
|
+
if not hasattr(self._original_widget, "mouse_event"):
|
|
114
|
+
return False
|
|
115
|
+
return self._original_widget.mouse_event((maxcol, self.height), event, button, col, row, focus)
|
|
116
|
+
|
|
117
|
+
def render(self, size: tuple[int], focus: bool = False) -> CompositeCanvas:
|
|
118
|
+
(maxcol,) = size
|
|
119
|
+
canv = CompositeCanvas(self._original_widget.render((maxcol, self.height), focus))
|
|
120
|
+
return canv
|
|
121
|
+
|
|
122
|
+
def __getattr__(self, name: str):
|
|
123
|
+
"""
|
|
124
|
+
Pass calls to box widget.
|
|
125
|
+
"""
|
|
126
|
+
return getattr(self.original_widget, name)
|