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/command_map.py
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Urwid CommandMap class
|
|
2
|
+
# Copyright (C) 2004-2011 Ian Ward
|
|
3
|
+
#
|
|
4
|
+
# This library is free software; you can redistribute it and/or
|
|
5
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
6
|
+
# License as published by the Free Software Foundation; either
|
|
7
|
+
# version 2.1 of the License, or (at your option) any later version.
|
|
8
|
+
#
|
|
9
|
+
# This library is distributed in the hope that it will be useful,
|
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
12
|
+
# Lesser General Public License for more details.
|
|
13
|
+
#
|
|
14
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
15
|
+
# License along with this library; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
17
|
+
#
|
|
18
|
+
# Urwid web site: https://urwid.org/
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
import enum
|
|
23
|
+
import typing
|
|
24
|
+
from typing import Iterator
|
|
25
|
+
|
|
26
|
+
if typing.TYPE_CHECKING:
|
|
27
|
+
from typing_extensions import Self
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class Command(str, enum.Enum):
|
|
31
|
+
REDRAW_SCREEN = "redraw screen"
|
|
32
|
+
UP = "cursor up"
|
|
33
|
+
DOWN = "cursor down"
|
|
34
|
+
LEFT = "cursor left"
|
|
35
|
+
RIGHT = "cursor right"
|
|
36
|
+
PAGE_UP = "cursor page up"
|
|
37
|
+
PAGE_DOWN = "cursor page down"
|
|
38
|
+
MAX_LEFT = "cursor max left"
|
|
39
|
+
MAX_RIGHT = "cursor max right"
|
|
40
|
+
ACTIVATE = "activate"
|
|
41
|
+
MENU = "menu"
|
|
42
|
+
SELECT_NEXT = "next selectable"
|
|
43
|
+
SELECT_PREVIOUS = "prev selectable"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
REDRAW_SCREEN = Command.REDRAW_SCREEN
|
|
47
|
+
CURSOR_UP = Command.UP
|
|
48
|
+
CURSOR_DOWN = Command.DOWN
|
|
49
|
+
CURSOR_LEFT = Command.LEFT
|
|
50
|
+
CURSOR_RIGHT = Command.RIGHT
|
|
51
|
+
CURSOR_PAGE_UP = Command.PAGE_UP
|
|
52
|
+
CURSOR_PAGE_DOWN = Command.PAGE_DOWN
|
|
53
|
+
CURSOR_MAX_LEFT = Command.MAX_LEFT
|
|
54
|
+
CURSOR_MAX_RIGHT = Command.MAX_RIGHT
|
|
55
|
+
ACTIVATE = Command.ACTIVATE
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class CommandMap(typing.Mapping[str, typing.Union[str, Command, None]]):
|
|
59
|
+
"""
|
|
60
|
+
dict-like object for looking up commands from keystrokes
|
|
61
|
+
|
|
62
|
+
Default values (key: command)::
|
|
63
|
+
|
|
64
|
+
'tab': 'next selectable',
|
|
65
|
+
'ctrl n': 'next selectable',
|
|
66
|
+
'shift tab': 'prev selectable',
|
|
67
|
+
'ctrl p': 'prev selectable',
|
|
68
|
+
'ctrl l': 'redraw screen',
|
|
69
|
+
'esc': 'menu',
|
|
70
|
+
'up': 'cursor up',
|
|
71
|
+
'down': 'cursor down',
|
|
72
|
+
'left': 'cursor left',
|
|
73
|
+
'right': 'cursor right',
|
|
74
|
+
'page up': 'cursor page up',
|
|
75
|
+
'page down': 'cursor page down',
|
|
76
|
+
'home': 'cursor max left',
|
|
77
|
+
'end': 'cursor max right',
|
|
78
|
+
' ': 'activate',
|
|
79
|
+
'enter': 'activate',
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
def __iter__(self) -> Iterator[str]:
|
|
83
|
+
return iter(self._command)
|
|
84
|
+
|
|
85
|
+
def __len__(self) -> int:
|
|
86
|
+
return len(self._command)
|
|
87
|
+
|
|
88
|
+
_command_defaults: typing.ClassVar[dict[str, str | Command]] = {
|
|
89
|
+
"tab": Command.SELECT_NEXT,
|
|
90
|
+
"ctrl n": Command.SELECT_NEXT,
|
|
91
|
+
"shift tab": Command.SELECT_PREVIOUS,
|
|
92
|
+
"ctrl p": Command.SELECT_PREVIOUS,
|
|
93
|
+
"ctrl l": Command.REDRAW_SCREEN,
|
|
94
|
+
"esc": Command.MENU,
|
|
95
|
+
"up": Command.UP,
|
|
96
|
+
"down": Command.DOWN,
|
|
97
|
+
"left": Command.LEFT,
|
|
98
|
+
"right": Command.RIGHT,
|
|
99
|
+
"page up": Command.PAGE_UP,
|
|
100
|
+
"page down": Command.PAGE_DOWN,
|
|
101
|
+
"home": Command.MAX_LEFT,
|
|
102
|
+
"end": Command.MAX_RIGHT,
|
|
103
|
+
" ": Command.ACTIVATE,
|
|
104
|
+
"enter": Command.ACTIVATE,
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
def __init__(self) -> None:
|
|
108
|
+
self._command = dict(self._command_defaults)
|
|
109
|
+
|
|
110
|
+
def restore_defaults(self) -> None:
|
|
111
|
+
self._command = dict(self._command_defaults)
|
|
112
|
+
|
|
113
|
+
def __getitem__(self, key: str) -> str | Command | None:
|
|
114
|
+
return self._command.get(key, None)
|
|
115
|
+
|
|
116
|
+
def __setitem__(self, key, command: str | Command) -> None:
|
|
117
|
+
self._command[key] = command
|
|
118
|
+
|
|
119
|
+
def __delitem__(self, key: str) -> None:
|
|
120
|
+
del self._command[key]
|
|
121
|
+
|
|
122
|
+
def clear_command(self, command: str | Command) -> None:
|
|
123
|
+
dk = [k for k, v in self._command.items() if v == command]
|
|
124
|
+
for k in dk:
|
|
125
|
+
del self._command[k]
|
|
126
|
+
|
|
127
|
+
def copy(self) -> Self:
|
|
128
|
+
"""
|
|
129
|
+
Return a new copy of this CommandMap, likely so we can modify
|
|
130
|
+
it separate from a shared one.
|
|
131
|
+
"""
|
|
132
|
+
c = self.__class__()
|
|
133
|
+
c._command = dict(self._command) # pylint: disable=protected-access
|
|
134
|
+
return c
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
command_map = CommandMap() # shared command mappings
|
urwid/container.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Urwid container widget classes
|
|
2
|
+
# Copyright (C) 2004-2012 Ian Ward
|
|
3
|
+
#
|
|
4
|
+
# This library is free software; you can redistribute it and/or
|
|
5
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
6
|
+
# License as published by the Free Software Foundation; either
|
|
7
|
+
# version 2.1 of the License, or (at your option) any later version.
|
|
8
|
+
#
|
|
9
|
+
# This library is distributed in the hope that it will be useful,
|
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
12
|
+
# Lesser General Public License for more details.
|
|
13
|
+
#
|
|
14
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
15
|
+
# License along with this library; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
17
|
+
#
|
|
18
|
+
# Urwid web site: https://urwid.org/
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
import warnings
|
|
24
|
+
|
|
25
|
+
from urwid.widget import (
|
|
26
|
+
Columns,
|
|
27
|
+
ColumnsError,
|
|
28
|
+
Frame,
|
|
29
|
+
FrameError,
|
|
30
|
+
GridFlow,
|
|
31
|
+
GridFlowError,
|
|
32
|
+
Overlay,
|
|
33
|
+
OverlayError,
|
|
34
|
+
Pile,
|
|
35
|
+
PileError,
|
|
36
|
+
WidgetContainerMixin,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
__all__ = (
|
|
40
|
+
"Columns",
|
|
41
|
+
"ColumnsError",
|
|
42
|
+
"Frame",
|
|
43
|
+
"FrameError",
|
|
44
|
+
"GridFlow",
|
|
45
|
+
"GridFlowError",
|
|
46
|
+
"Overlay",
|
|
47
|
+
"OverlayError",
|
|
48
|
+
"Pile",
|
|
49
|
+
"PileError",
|
|
50
|
+
"WidgetContainerMixin",
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
warnings.warn(
|
|
54
|
+
f"{__name__!r} is not expected to be imported directly. "
|
|
55
|
+
'Please use public access from "urwid" package. '
|
|
56
|
+
f"Module {__name__!r} is deprecated and will be removed in the future.",
|
|
57
|
+
DeprecationWarning,
|
|
58
|
+
stacklevel=3,
|
|
59
|
+
)
|
urwid/decoration.py
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Urwid widget decoration classes
|
|
2
|
+
# Copyright (C) 2004-2012 Ian Ward
|
|
3
|
+
#
|
|
4
|
+
# This library is free software; you can redistribute it and/or
|
|
5
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
6
|
+
# License as published by the Free Software Foundation; either
|
|
7
|
+
# version 2.1 of the License, or (at your option) any later version.
|
|
8
|
+
#
|
|
9
|
+
# This library is distributed in the hope that it will be useful,
|
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
12
|
+
# Lesser General Public License for more details.
|
|
13
|
+
#
|
|
14
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
15
|
+
# License along with this library; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
17
|
+
#
|
|
18
|
+
# Urwid web site: https://urwid.org/
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
import warnings
|
|
24
|
+
|
|
25
|
+
from urwid.widget import (
|
|
26
|
+
AttrMap,
|
|
27
|
+
AttrMapError,
|
|
28
|
+
AttrWrap,
|
|
29
|
+
BoxAdapter,
|
|
30
|
+
BoxAdapterError,
|
|
31
|
+
Filler,
|
|
32
|
+
FillerError,
|
|
33
|
+
Padding,
|
|
34
|
+
PaddingError,
|
|
35
|
+
WidgetDecoration,
|
|
36
|
+
WidgetDisable,
|
|
37
|
+
WidgetPlaceholder,
|
|
38
|
+
calculate_top_bottom_filler,
|
|
39
|
+
normalize_valign,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
__all__ = (
|
|
43
|
+
"AttrMap",
|
|
44
|
+
"AttrMapError",
|
|
45
|
+
"AttrWrap",
|
|
46
|
+
"BoxAdapter",
|
|
47
|
+
"BoxAdapterError",
|
|
48
|
+
"Filler",
|
|
49
|
+
"FillerError",
|
|
50
|
+
"Padding",
|
|
51
|
+
"PaddingError",
|
|
52
|
+
"WidgetDecoration",
|
|
53
|
+
"WidgetDisable",
|
|
54
|
+
"WidgetPlaceholder",
|
|
55
|
+
"calculate_top_bottom_filler",
|
|
56
|
+
"normalize_valign",
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
warnings.warn(
|
|
60
|
+
f"{__name__!r} is not expected to be imported directly. "
|
|
61
|
+
'Please use public access from "urwid" package. '
|
|
62
|
+
f"Module {__name__!r} is deprecated and will be removed in the future.",
|
|
63
|
+
DeprecationWarning,
|
|
64
|
+
stacklevel=3,
|
|
65
|
+
)
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"""Package with Display implementations for urwid."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
import typing
|
|
7
|
+
|
|
8
|
+
__all__ = (
|
|
9
|
+
"BLACK",
|
|
10
|
+
"BROWN",
|
|
11
|
+
"DARK_BLUE",
|
|
12
|
+
"DARK_CYAN",
|
|
13
|
+
"DARK_GRAY",
|
|
14
|
+
"DARK_GREEN",
|
|
15
|
+
"DARK_MAGENTA",
|
|
16
|
+
"DARK_RED",
|
|
17
|
+
"DEFAULT",
|
|
18
|
+
"LIGHT_BLUE",
|
|
19
|
+
"LIGHT_CYAN",
|
|
20
|
+
"LIGHT_GRAY",
|
|
21
|
+
"LIGHT_GREEN",
|
|
22
|
+
"LIGHT_MAGENTA",
|
|
23
|
+
"LIGHT_RED",
|
|
24
|
+
"UPDATE_PALETTE_ENTRY",
|
|
25
|
+
"WHITE",
|
|
26
|
+
"YELLOW",
|
|
27
|
+
"AttrSpec",
|
|
28
|
+
"AttrSpecError",
|
|
29
|
+
"BaseScreen",
|
|
30
|
+
"RealTerminal",
|
|
31
|
+
"ScreenError",
|
|
32
|
+
# Lazy imported
|
|
33
|
+
"html_fragment",
|
|
34
|
+
"lcd",
|
|
35
|
+
"raw",
|
|
36
|
+
"web",
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
from . import raw
|
|
40
|
+
from .common import (
|
|
41
|
+
BLACK,
|
|
42
|
+
BROWN,
|
|
43
|
+
DARK_BLUE,
|
|
44
|
+
DARK_CYAN,
|
|
45
|
+
DARK_GRAY,
|
|
46
|
+
DARK_GREEN,
|
|
47
|
+
DARK_MAGENTA,
|
|
48
|
+
DARK_RED,
|
|
49
|
+
DEFAULT,
|
|
50
|
+
LIGHT_BLUE,
|
|
51
|
+
LIGHT_CYAN,
|
|
52
|
+
LIGHT_GRAY,
|
|
53
|
+
LIGHT_GREEN,
|
|
54
|
+
LIGHT_MAGENTA,
|
|
55
|
+
LIGHT_RED,
|
|
56
|
+
UPDATE_PALETTE_ENTRY,
|
|
57
|
+
WHITE,
|
|
58
|
+
YELLOW,
|
|
59
|
+
AttrSpec,
|
|
60
|
+
AttrSpecError,
|
|
61
|
+
BaseScreen,
|
|
62
|
+
RealTerminal,
|
|
63
|
+
ScreenError,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
try:
|
|
67
|
+
from . import curses
|
|
68
|
+
|
|
69
|
+
__all__ += ("curses",)
|
|
70
|
+
except ImportError:
|
|
71
|
+
pass
|
|
72
|
+
|
|
73
|
+
# Moved modules handling
|
|
74
|
+
__locals: dict[str, typing.Any] = locals() # use mutable access for pure lazy loading
|
|
75
|
+
|
|
76
|
+
# Lazy load modules
|
|
77
|
+
_lazy_load: frozenset[str] = frozenset(
|
|
78
|
+
(
|
|
79
|
+
"html_fragment",
|
|
80
|
+
"lcd",
|
|
81
|
+
"web",
|
|
82
|
+
)
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def __getattr__(name: str) -> typing.Any:
|
|
87
|
+
"""Get attributes lazy.
|
|
88
|
+
|
|
89
|
+
:return: attribute by name
|
|
90
|
+
:raises AttributeError: attribute is not defined for lazy load
|
|
91
|
+
"""
|
|
92
|
+
if name in _lazy_load:
|
|
93
|
+
mod = importlib.import_module(f"{__package__}.{name}")
|
|
94
|
+
__locals[name] = mod
|
|
95
|
+
return mod
|
|
96
|
+
|
|
97
|
+
raise AttributeError(f"{name} not found in {__package__}")
|