urwid 2.6.15__py3-none-any.whl → 3.0.5__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.
- urwid/__init__.py +30 -20
- urwid/canvas.py +34 -53
- urwid/command_map.py +6 -4
- urwid/container.py +1 -1
- urwid/decoration.py +1 -1
- urwid/display/__init__.py +53 -48
- urwid/display/_posix_raw_display.py +20 -8
- urwid/display/_raw_display_base.py +21 -16
- urwid/display/_win32_raw_display.py +16 -17
- urwid/display/common.py +45 -74
- urwid/display/curses.py +3 -5
- urwid/display/escape.py +28 -13
- urwid/display/lcd.py +8 -10
- urwid/display/web.py +11 -16
- urwid/event_loop/asyncio_loop.py +35 -15
- urwid/event_loop/main_loop.py +18 -23
- urwid/event_loop/tornado_loop.py +4 -5
- urwid/event_loop/trio_loop.py +1 -1
- urwid/font.py +19 -22
- urwid/numedit.py +65 -65
- urwid/signals.py +19 -27
- urwid/split_repr.py +9 -3
- urwid/str_util.py +105 -60
- urwid/text_layout.py +14 -13
- urwid/util.py +8 -19
- urwid/version.py +22 -4
- urwid/vterm.py +20 -47
- urwid/widget/__init__.py +0 -6
- urwid/widget/attr_map.py +10 -10
- urwid/widget/attr_wrap.py +11 -13
- urwid/widget/bar_graph.py +3 -8
- urwid/widget/big_text.py +8 -9
- urwid/widget/box_adapter.py +6 -6
- urwid/widget/columns.py +52 -83
- urwid/widget/container.py +29 -75
- urwid/widget/divider.py +6 -6
- urwid/widget/edit.py +50 -50
- urwid/widget/filler.py +14 -14
- urwid/widget/frame.py +31 -40
- urwid/widget/grid_flow.py +25 -110
- urwid/widget/line_box.py +31 -18
- urwid/widget/listbox.py +16 -51
- urwid/widget/monitored_list.py +75 -49
- urwid/widget/overlay.py +4 -37
- urwid/widget/padding.py +31 -68
- urwid/widget/pile.py +179 -158
- urwid/widget/popup.py +2 -2
- urwid/widget/progress_bar.py +17 -18
- urwid/widget/scrollable.py +26 -34
- urwid/widget/solid_fill.py +3 -3
- urwid/widget/text.py +44 -30
- urwid/widget/treetools.py +27 -48
- urwid/widget/widget.py +13 -130
- urwid/widget/widget_decoration.py +6 -35
- urwid/widget/wimp.py +61 -61
- urwid/wimp.py +1 -1
- {urwid-2.6.15.dist-info → urwid-3.0.5.dist-info}/METADATA +24 -24
- urwid-3.0.5.dist-info/RECORD +74 -0
- {urwid-2.6.15.dist-info → urwid-3.0.5.dist-info}/WHEEL +1 -1
- urwid-2.6.15.dist-info/RECORD +0 -74
- {urwid-2.6.15.dist-info → urwid-3.0.5.dist-info/licenses}/COPYING +0 -0
- {urwid-2.6.15.dist-info → urwid-3.0.5.dist-info}/top_level.txt +0 -0
urwid/widget/monitored_list.py
CHANGED
|
@@ -37,7 +37,7 @@ _T = typing.TypeVar("_T")
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
def _call_modified(
|
|
40
|
-
fn: Callable[Concatenate[MonitoredList, ArgSpec], Ret]
|
|
40
|
+
fn: Callable[Concatenate[MonitoredList, ArgSpec], Ret],
|
|
41
41
|
) -> Callable[Concatenate[MonitoredList, ArgSpec], Ret]:
|
|
42
42
|
@functools.wraps(fn)
|
|
43
43
|
def call_modified_wrapper(self: MonitoredList, *args: ArgSpec.args, **kwargs: ArgSpec.kwargs) -> Ret:
|
|
@@ -48,7 +48,7 @@ def _call_modified(
|
|
|
48
48
|
return call_modified_wrapper
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
class MonitoredList(
|
|
51
|
+
class MonitoredList(list[_T], typing.Generic[_T]):
|
|
52
52
|
"""
|
|
53
53
|
This class can trigger a callback any time its contents are changed
|
|
54
54
|
with the usual list operations append, extend, etc.
|
|
@@ -63,7 +63,7 @@ class MonitoredList(typing.List[_T], typing.Generic[_T]):
|
|
|
63
63
|
time the list is modified. Callback's return value is ignored.
|
|
64
64
|
|
|
65
65
|
>>> import sys
|
|
66
|
-
>>> ml = MonitoredList([1,2,3])
|
|
66
|
+
>>> ml = MonitoredList([1, 2, 3])
|
|
67
67
|
>>> ml.set_modified_callback(lambda: sys.stdout.write("modified\\n"))
|
|
68
68
|
>>> ml
|
|
69
69
|
MonitoredList([1, 2, 3])
|
|
@@ -167,7 +167,7 @@ class MonitoredFocusList(MonitoredList[_T], typing.Generic[_T]):
|
|
|
167
167
|
>>> ml = MonitoredFocusList([10, 11, 12, 13, 14], focus=3)
|
|
168
168
|
>>> ml
|
|
169
169
|
MonitoredFocusList([10, 11, 12, 13, 14], focus=3)
|
|
170
|
-
>>> del
|
|
170
|
+
>>> del ml[1]
|
|
171
171
|
>>> ml
|
|
172
172
|
MonitoredFocusList([10, 12, 13, 14], focus=2)
|
|
173
173
|
>>> ml[:2] = [50, 51, 52, 53]
|
|
@@ -199,7 +199,7 @@ class MonitoredFocusList(MonitoredList[_T], typing.Generic[_T]):
|
|
|
199
199
|
Return the index of the item "in focus" or None if
|
|
200
200
|
the list is empty.
|
|
201
201
|
|
|
202
|
-
>>> MonitoredFocusList([1,2,3], focus=2).focus
|
|
202
|
+
>>> MonitoredFocusList([1, 2, 3], focus=2).focus
|
|
203
203
|
2
|
|
204
204
|
>>> MonitoredFocusList().focus
|
|
205
205
|
"""
|
|
@@ -221,9 +221,11 @@ class MonitoredFocusList(MonitoredList[_T], typing.Generic[_T]):
|
|
|
221
221
|
instance with set_focus_changed_callback().
|
|
222
222
|
|
|
223
223
|
>>> ml = MonitoredFocusList([9, 10, 11])
|
|
224
|
-
>>> ml.focus = 2
|
|
224
|
+
>>> ml.focus = 2
|
|
225
|
+
... ml.focus
|
|
225
226
|
2
|
|
226
|
-
>>> ml.focus = 0
|
|
227
|
+
>>> ml.focus = 0
|
|
228
|
+
... ml.focus
|
|
227
229
|
0
|
|
228
230
|
>>> ml.focus = -2
|
|
229
231
|
Traceback (most recent call last):
|
|
@@ -245,7 +247,8 @@ class MonitoredFocusList(MonitoredList[_T], typing.Generic[_T]):
|
|
|
245
247
|
def _get_focus(self) -> int | None:
|
|
246
248
|
warnings.warn(
|
|
247
249
|
f"method `{self.__class__.__name__}._get_focus` is deprecated, "
|
|
248
|
-
f"please use `{self.__class__.__name__}.focus` property"
|
|
250
|
+
f"please use `{self.__class__.__name__}.focus` property."
|
|
251
|
+
"API will be removed in version 4.0.",
|
|
249
252
|
DeprecationWarning,
|
|
250
253
|
stacklevel=3,
|
|
251
254
|
)
|
|
@@ -254,7 +257,8 @@ class MonitoredFocusList(MonitoredList[_T], typing.Generic[_T]):
|
|
|
254
257
|
def _set_focus(self, index: int) -> None:
|
|
255
258
|
warnings.warn(
|
|
256
259
|
f"method `{self.__class__.__name__}._set_focus` is deprecated, "
|
|
257
|
-
f"please use `{self.__class__.__name__}.focus` property"
|
|
260
|
+
f"please use `{self.__class__.__name__}.focus` property."
|
|
261
|
+
"API will be removed in version 4.0.",
|
|
258
262
|
DeprecationWarning,
|
|
259
263
|
stacklevel=3,
|
|
260
264
|
)
|
|
@@ -272,7 +276,7 @@ class MonitoredFocusList(MonitoredList[_T], typing.Generic[_T]):
|
|
|
272
276
|
new_focus -- new focus index
|
|
273
277
|
|
|
274
278
|
>>> import sys
|
|
275
|
-
>>> ml = MonitoredFocusList([1,2,3], focus=1)
|
|
279
|
+
>>> ml = MonitoredFocusList([1, 2, 3], focus=1)
|
|
276
280
|
>>> ml.set_focus_changed_callback(lambda f: sys.stdout.write("focus: %d\\n" % (f,)))
|
|
277
281
|
>>> ml
|
|
278
282
|
MonitoredFocusList([1, 2, 3], focus=1)
|
|
@@ -357,28 +361,38 @@ class MonitoredFocusList(MonitoredList[_T], typing.Generic[_T]):
|
|
|
357
361
|
|
|
358
362
|
def __delitem__(self, y: int | slice) -> None:
|
|
359
363
|
"""
|
|
360
|
-
>>> ml = MonitoredFocusList([0,1,2,3,4], focus=2)
|
|
361
|
-
>>> del ml[3]
|
|
364
|
+
>>> ml = MonitoredFocusList([0, 1, 2, 3, 4], focus=2)
|
|
365
|
+
>>> del ml[3]
|
|
366
|
+
>>> ml
|
|
362
367
|
MonitoredFocusList([0, 1, 2, 4], focus=2)
|
|
363
|
-
>>> del ml[-1]
|
|
368
|
+
>>> del ml[-1]
|
|
369
|
+
>>> ml
|
|
364
370
|
MonitoredFocusList([0, 1, 2], focus=2)
|
|
365
|
-
>>> del ml[0]
|
|
371
|
+
>>> del ml[0]
|
|
372
|
+
>>> ml
|
|
366
373
|
MonitoredFocusList([1, 2], focus=1)
|
|
367
|
-
>>> del ml[1]
|
|
374
|
+
>>> del ml[1]
|
|
375
|
+
>>> ml
|
|
368
376
|
MonitoredFocusList([1], focus=0)
|
|
369
|
-
>>> del ml[0]
|
|
377
|
+
>>> del ml[0]
|
|
378
|
+
>>> ml
|
|
370
379
|
MonitoredFocusList([], focus=None)
|
|
371
|
-
>>> ml = MonitoredFocusList([5,4,6,4,5,4,6,4,5], focus=4)
|
|
372
|
-
>>> del ml[1::2]
|
|
380
|
+
>>> ml = MonitoredFocusList([5, 4, 6, 4, 5, 4, 6, 4, 5], focus=4)
|
|
381
|
+
>>> del ml[1::2]
|
|
382
|
+
>>> ml
|
|
373
383
|
MonitoredFocusList([5, 6, 5, 6, 5], focus=2)
|
|
374
|
-
>>> del ml[::2]
|
|
384
|
+
>>> del ml[::2]
|
|
385
|
+
>>> ml
|
|
375
386
|
MonitoredFocusList([6, 6], focus=1)
|
|
376
|
-
>>> ml = MonitoredFocusList([0,1,2,3,4,6,7], focus=2)
|
|
377
|
-
>>> del ml[-2:]
|
|
387
|
+
>>> ml = MonitoredFocusList([0, 1, 2, 3, 4, 6, 7], focus=2)
|
|
388
|
+
>>> del ml[-2:]
|
|
389
|
+
>>> ml
|
|
378
390
|
MonitoredFocusList([0, 1, 2, 3, 4], focus=2)
|
|
379
|
-
>>> del ml[-4:-2]
|
|
391
|
+
>>> del ml[-4:-2]
|
|
392
|
+
>>> ml
|
|
380
393
|
MonitoredFocusList([0, 3, 4], focus=1)
|
|
381
|
-
>>> del ml[:]
|
|
394
|
+
>>> del ml[:]
|
|
395
|
+
>>> ml
|
|
382
396
|
MonitoredFocusList([], focus=None)
|
|
383
397
|
"""
|
|
384
398
|
if isinstance(y, slice):
|
|
@@ -397,8 +411,8 @@ class MonitoredFocusList(MonitoredList[_T], typing.Generic[_T]):
|
|
|
397
411
|
def __setitem__(self, i: int | slice, y: _T | Collection[_T]) -> None:
|
|
398
412
|
"""
|
|
399
413
|
>>> def modified(indices, new_items):
|
|
400
|
-
... print(f"range{indices!r} <- {new_items!r}"
|
|
401
|
-
>>> ml = MonitoredFocusList([0,1,2,3], focus=2)
|
|
414
|
+
... print(f"range{indices!r} <- {new_items!r}")
|
|
415
|
+
>>> ml = MonitoredFocusList([0, 1, 2, 3], focus=2)
|
|
402
416
|
>>> ml.set_validate_contents_modified(modified)
|
|
403
417
|
>>> ml[0] = 9
|
|
404
418
|
range(0, 1, 1) <- [9]
|
|
@@ -433,8 +447,8 @@ class MonitoredFocusList(MonitoredList[_T], typing.Generic[_T]):
|
|
|
433
447
|
def __imul__(self, n: int):
|
|
434
448
|
"""
|
|
435
449
|
>>> def modified(indices, new_items):
|
|
436
|
-
... print(f"range{indices!r} <- {list(new_items)!r}"
|
|
437
|
-
>>> ml = MonitoredFocusList([0,1,2], focus=2)
|
|
450
|
+
... print(f"range{indices!r} <- {list(new_items)!r}")
|
|
451
|
+
>>> ml = MonitoredFocusList([0, 1, 2], focus=2)
|
|
438
452
|
>>> ml.set_validate_contents_modified(modified)
|
|
439
453
|
>>> ml *= 3
|
|
440
454
|
range(3, 3, 1) <- [0, 1, 2, 0, 1, 2]
|
|
@@ -456,8 +470,8 @@ class MonitoredFocusList(MonitoredList[_T], typing.Generic[_T]):
|
|
|
456
470
|
def append(self, item: _T) -> None:
|
|
457
471
|
"""
|
|
458
472
|
>>> def modified(indices, new_items):
|
|
459
|
-
... print(f"range{indices!r} <- {new_items!r}"
|
|
460
|
-
>>> ml = MonitoredFocusList([0,1,2], focus=2)
|
|
473
|
+
... print(f"range{indices!r} <- {new_items!r}")
|
|
474
|
+
>>> ml = MonitoredFocusList([0, 1, 2], focus=2)
|
|
461
475
|
>>> ml.set_validate_contents_modified(modified)
|
|
462
476
|
>>> ml.append(6)
|
|
463
477
|
range(3, 3, 1) <- [6]
|
|
@@ -469,10 +483,10 @@ class MonitoredFocusList(MonitoredList[_T], typing.Generic[_T]):
|
|
|
469
483
|
def extend(self, items: Collection[_T]) -> None:
|
|
470
484
|
"""
|
|
471
485
|
>>> def modified(indices, new_items):
|
|
472
|
-
... print(f"range{indices!r} <- {list(new_items)!r}"
|
|
473
|
-
>>> ml = MonitoredFocusList([0,1,2], focus=2)
|
|
486
|
+
... print(f"range{indices!r} <- {list(new_items)!r}")
|
|
487
|
+
>>> ml = MonitoredFocusList([0, 1, 2], focus=2)
|
|
474
488
|
>>> ml.set_validate_contents_modified(modified)
|
|
475
|
-
>>> ml.extend((6,7,8))
|
|
489
|
+
>>> ml.extend((6, 7, 8))
|
|
476
490
|
range(3, 3, 1) <- [6, 7, 8]
|
|
477
491
|
"""
|
|
478
492
|
focus = self._adjust_focus_on_contents_modified(slice(len(self), len(self)), items)
|
|
@@ -481,12 +495,15 @@ class MonitoredFocusList(MonitoredList[_T], typing.Generic[_T]):
|
|
|
481
495
|
|
|
482
496
|
def insert(self, index: int, item: _T) -> None:
|
|
483
497
|
"""
|
|
484
|
-
>>> ml = MonitoredFocusList([0,1,2,3], focus=2)
|
|
485
|
-
>>> ml.insert(-1, -1)
|
|
498
|
+
>>> ml = MonitoredFocusList([0, 1, 2, 3], focus=2)
|
|
499
|
+
>>> ml.insert(-1, -1)
|
|
500
|
+
>>> ml
|
|
486
501
|
MonitoredFocusList([0, 1, 2, -1, 3], focus=2)
|
|
487
|
-
>>> ml.insert(0, -2)
|
|
502
|
+
>>> ml.insert(0, -2)
|
|
503
|
+
>>> ml
|
|
488
504
|
MonitoredFocusList([-2, 0, 1, 2, -1, 3], focus=3)
|
|
489
|
-
>>> ml.insert(3, -3)
|
|
505
|
+
>>> ml.insert(3, -3)
|
|
506
|
+
>>> ml
|
|
490
507
|
MonitoredFocusList([-2, 0, 1, -3, 2, -1, 3], focus=4)
|
|
491
508
|
"""
|
|
492
509
|
focus = self._adjust_focus_on_contents_modified(slice(index, index), [item])
|
|
@@ -495,18 +512,22 @@ class MonitoredFocusList(MonitoredList[_T], typing.Generic[_T]):
|
|
|
495
512
|
|
|
496
513
|
def pop(self, index: int = -1) -> _T:
|
|
497
514
|
"""
|
|
498
|
-
>>> ml = MonitoredFocusList([-2,0,1
|
|
499
|
-
>>> ml.pop(3)
|
|
515
|
+
>>> ml = MonitoredFocusList([-2, 0, 1, -3, 2, 3], focus=4)
|
|
516
|
+
>>> ml.pop(3)
|
|
500
517
|
-3
|
|
518
|
+
>>> ml
|
|
501
519
|
MonitoredFocusList([-2, 0, 1, 2, 3], focus=3)
|
|
502
|
-
>>> ml.pop(0)
|
|
520
|
+
>>> ml.pop(0)
|
|
503
521
|
-2
|
|
522
|
+
>>> ml
|
|
504
523
|
MonitoredFocusList([0, 1, 2, 3], focus=2)
|
|
505
|
-
>>> ml.pop(-1)
|
|
524
|
+
>>> ml.pop(-1)
|
|
506
525
|
3
|
|
526
|
+
>>> ml
|
|
507
527
|
MonitoredFocusList([0, 1, 2], focus=2)
|
|
508
|
-
>>> ml.pop(2)
|
|
528
|
+
>>> ml.pop(2)
|
|
509
529
|
2
|
|
530
|
+
>>> ml
|
|
510
531
|
MonitoredFocusList([0, 1], focus=1)
|
|
511
532
|
"""
|
|
512
533
|
focus = self._adjust_focus_on_contents_modified(slice(index, index + 1 or None))
|
|
@@ -516,12 +537,15 @@ class MonitoredFocusList(MonitoredList[_T], typing.Generic[_T]):
|
|
|
516
537
|
|
|
517
538
|
def remove(self, value: _T) -> None:
|
|
518
539
|
"""
|
|
519
|
-
>>> ml = MonitoredFocusList([-2,0,1
|
|
520
|
-
>>> ml.remove(-3)
|
|
540
|
+
>>> ml = MonitoredFocusList([-2, 0, 1, -3, 2, -1, 3], focus=4)
|
|
541
|
+
>>> ml.remove(-3)
|
|
542
|
+
>>> ml
|
|
521
543
|
MonitoredFocusList([-2, 0, 1, 2, -1, 3], focus=3)
|
|
522
|
-
>>> ml.remove(-2)
|
|
544
|
+
>>> ml.remove(-2)
|
|
545
|
+
>>> ml
|
|
523
546
|
MonitoredFocusList([0, 1, 2, -1, 3], focus=2)
|
|
524
|
-
>>> ml.remove(3)
|
|
547
|
+
>>> ml.remove(3)
|
|
548
|
+
>>> ml
|
|
525
549
|
MonitoredFocusList([0, 1, 2, -1], focus=2)
|
|
526
550
|
"""
|
|
527
551
|
index = self.index(value)
|
|
@@ -531,8 +555,9 @@ class MonitoredFocusList(MonitoredList[_T], typing.Generic[_T]):
|
|
|
531
555
|
|
|
532
556
|
def reverse(self) -> None:
|
|
533
557
|
"""
|
|
534
|
-
>>> ml = MonitoredFocusList([0,1,2,3,4], focus=1)
|
|
535
|
-
>>> ml.reverse()
|
|
558
|
+
>>> ml = MonitoredFocusList([0, 1, 2, 3, 4], focus=1)
|
|
559
|
+
>>> ml.reverse()
|
|
560
|
+
>>> ml
|
|
536
561
|
MonitoredFocusList([4, 3, 2, 1, 0], focus=3)
|
|
537
562
|
"""
|
|
538
563
|
rval = super().reverse()
|
|
@@ -541,8 +566,9 @@ class MonitoredFocusList(MonitoredList[_T], typing.Generic[_T]):
|
|
|
541
566
|
|
|
542
567
|
def sort(self, **kwargs) -> None:
|
|
543
568
|
"""
|
|
544
|
-
>>> ml = MonitoredFocusList([-2,0,1
|
|
545
|
-
>>> ml.sort()
|
|
569
|
+
>>> ml = MonitoredFocusList([-2, 0, 1, -3, 2, -1, 3], focus=4)
|
|
570
|
+
>>> ml.sort()
|
|
571
|
+
>>> ml
|
|
546
572
|
MonitoredFocusList([-3, -2, -1, 0, 1, 2, 3], focus=5)
|
|
547
573
|
"""
|
|
548
574
|
if not self:
|
urwid/widget/overlay.py
CHANGED
|
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import typing
|
|
4
4
|
import warnings
|
|
5
|
+
from collections.abc import MutableSequence
|
|
5
6
|
|
|
6
7
|
from urwid.canvas import CanvasOverlay, CompositeCanvas
|
|
7
8
|
from urwid.split_repr import remove_defaults
|
|
@@ -28,7 +29,7 @@ from .padding import calculate_left_right_padding
|
|
|
28
29
|
from .widget import Widget, WidgetError, WidgetWarning
|
|
29
30
|
|
|
30
31
|
if typing.TYPE_CHECKING:
|
|
31
|
-
from collections.abc import Iterator,
|
|
32
|
+
from collections.abc import Iterator, Sequence
|
|
32
33
|
|
|
33
34
|
from typing_extensions import Literal
|
|
34
35
|
|
|
@@ -582,15 +583,6 @@ class Overlay(Widget, WidgetContainerMixin, WidgetContainerListContentsMixin, ty
|
|
|
582
583
|
"""
|
|
583
584
|
return self.top_w
|
|
584
585
|
|
|
585
|
-
def _get_focus(self) -> TopWidget:
|
|
586
|
-
warnings.warn(
|
|
587
|
-
f"method `{self.__class__.__name__}._get_focus` is deprecated, "
|
|
588
|
-
f"please use `{self.__class__.__name__}.focus` property",
|
|
589
|
-
DeprecationWarning,
|
|
590
|
-
stacklevel=3,
|
|
591
|
-
)
|
|
592
|
-
return self.top_w
|
|
593
|
-
|
|
594
586
|
@property
|
|
595
587
|
def focus_position(self) -> Literal[1]:
|
|
596
588
|
"""
|
|
@@ -608,30 +600,6 @@ class Overlay(Widget, WidgetContainerMixin, WidgetContainerListContentsMixin, ty
|
|
|
608
600
|
if position != 1:
|
|
609
601
|
raise IndexError(f"Overlay widget focus_position currently must always be set to 1, not {position}")
|
|
610
602
|
|
|
611
|
-
def _get_focus_position(self) -> int | None:
|
|
612
|
-
warnings.warn(
|
|
613
|
-
f"method `{self.__class__.__name__}._get_focus_position` is deprecated, "
|
|
614
|
-
f"please use `{self.__class__.__name__}.focus_position` property",
|
|
615
|
-
DeprecationWarning,
|
|
616
|
-
stacklevel=3,
|
|
617
|
-
)
|
|
618
|
-
return 1
|
|
619
|
-
|
|
620
|
-
def _set_focus_position(self, position: int) -> None:
|
|
621
|
-
"""
|
|
622
|
-
Set the widget in focus.
|
|
623
|
-
|
|
624
|
-
position -- index of child widget to be made focus
|
|
625
|
-
"""
|
|
626
|
-
warnings.warn(
|
|
627
|
-
f"method `{self.__class__.__name__}._set_focus_position` is deprecated, "
|
|
628
|
-
f"please use `{self.__class__.__name__}.focus_position` property",
|
|
629
|
-
DeprecationWarning,
|
|
630
|
-
stacklevel=3,
|
|
631
|
-
)
|
|
632
|
-
if position != 1:
|
|
633
|
-
raise IndexError(f"Overlay widget focus_position currently must always be set to 1, not {position}")
|
|
634
|
-
|
|
635
603
|
@property
|
|
636
604
|
def contents(self) -> MutableSequence[tuple[TopWidget | BottomWidget, OverlayOptions]]:
|
|
637
605
|
"""
|
|
@@ -658,14 +626,13 @@ class Overlay(Widget, WidgetContainerMixin, WidgetContainerListContentsMixin, ty
|
|
|
658
626
|
|
|
659
627
|
# noinspection PyMethodParameters
|
|
660
628
|
class OverlayContents(
|
|
661
|
-
|
|
662
|
-
|
|
629
|
+
MutableSequence[
|
|
630
|
+
tuple[
|
|
663
631
|
typing.Union[TopWidget, BottomWidget],
|
|
664
632
|
OverlayOptions,
|
|
665
633
|
]
|
|
666
634
|
]
|
|
667
635
|
):
|
|
668
|
-
|
|
669
636
|
# pylint: disable=no-self-argument
|
|
670
637
|
def __len__(inner_self) -> int:
|
|
671
638
|
return 2
|
urwid/widget/padding.py
CHANGED
|
@@ -100,27 +100,27 @@ class Padding(WidgetDecoration[WrappedWidget], typing.Generic[WrappedWidget]):
|
|
|
100
100
|
>>> def pr(w):
|
|
101
101
|
... with set_temporary_encoding("utf-8"):
|
|
102
102
|
... for t in w.render(size).text:
|
|
103
|
-
... print(f"|{t.decode('utf-8')}|"
|
|
104
|
-
>>> pr(Padding(Text(
|
|
103
|
+
... print(f"|{t.decode('utf-8')}|")
|
|
104
|
+
>>> pr(Padding(Text("Head"), ("relative", 20), "pack"))
|
|
105
105
|
| Head |
|
|
106
|
-
>>> pr(Padding(Divider(
|
|
106
|
+
>>> pr(Padding(Divider("-"), left=2, right=1))
|
|
107
107
|
| ---- |
|
|
108
|
-
>>> pr(Padding(Divider(
|
|
108
|
+
>>> pr(Padding(Divider("*"), "center", 3))
|
|
109
109
|
| *** |
|
|
110
|
-
>>> p=Padding(Text(
|
|
110
|
+
>>> p = Padding(Text("1234"), "left", 2, None, 1, 1)
|
|
111
111
|
>>> p
|
|
112
112
|
<Padding fixed/flow widget <Text fixed/flow widget '1234'> left=1 right=1 width=2>
|
|
113
|
-
>>> pr(p)
|
|
113
|
+
>>> pr(p) # align against left
|
|
114
114
|
| 12 |
|
|
115
115
|
| 34 |
|
|
116
|
-
>>> p.align =
|
|
117
|
-
>>> pr(p)
|
|
116
|
+
>>> p.align = "right"
|
|
117
|
+
>>> pr(p) # align against right
|
|
118
118
|
| 12 |
|
|
119
119
|
| 34 |
|
|
120
|
-
>>> pr(Padding(Text(
|
|
120
|
+
>>> pr(Padding(Text("hi\\nthere"), "right", "pack")) # pack text first
|
|
121
121
|
| hi |
|
|
122
122
|
| there|
|
|
123
|
-
>>> pr(Padding(BigText("1,2,3", FontRegistry[
|
|
123
|
+
>>> pr(Padding(BigText("1,2,3", FontRegistry["Thin 3x3"]()), width="clip"))
|
|
124
124
|
| ┐ ┌─┐|
|
|
125
125
|
| │ ┌─┘|
|
|
126
126
|
| ┴ ,└─ |
|
|
@@ -215,24 +215,6 @@ class Padding(WidgetDecoration[WrappedWidget], typing.Generic[WrappedWidget]):
|
|
|
215
215
|
self._align_type, self._align_amount = normalize_align(align, PaddingError)
|
|
216
216
|
self._invalidate()
|
|
217
217
|
|
|
218
|
-
def _get_align(self) -> Literal["left", "center", "right"] | tuple[Literal["relative"], int]:
|
|
219
|
-
warnings.warn(
|
|
220
|
-
f"Method `{self.__class__.__name__}._get_align` is deprecated, "
|
|
221
|
-
f"please use property `{self.__class__.__name__}.align`",
|
|
222
|
-
DeprecationWarning,
|
|
223
|
-
stacklevel=2,
|
|
224
|
-
)
|
|
225
|
-
return self.align
|
|
226
|
-
|
|
227
|
-
def _set_align(self, align: Literal["left", "center", "right"] | tuple[Literal["relative"], int]) -> None:
|
|
228
|
-
warnings.warn(
|
|
229
|
-
f"Method `{self.__class__.__name__}._set_align` is deprecated, "
|
|
230
|
-
f"please use property `{self.__class__.__name__}.align`",
|
|
231
|
-
DeprecationWarning,
|
|
232
|
-
stacklevel=2,
|
|
233
|
-
)
|
|
234
|
-
self.align = align
|
|
235
|
-
|
|
236
218
|
@property
|
|
237
219
|
def width(
|
|
238
220
|
self,
|
|
@@ -261,24 +243,6 @@ class Padding(WidgetDecoration[WrappedWidget], typing.Generic[WrappedWidget]):
|
|
|
261
243
|
self._width_type, self._width_amount = normalize_width(width, PaddingError)
|
|
262
244
|
self._invalidate()
|
|
263
245
|
|
|
264
|
-
def _get_width(self) -> Literal["clip", "pack"] | int | tuple[Literal["relative"], int]:
|
|
265
|
-
warnings.warn(
|
|
266
|
-
f"Method `{self.__class__.__name__}._get_width` is deprecated, "
|
|
267
|
-
f"please use property `{self.__class__.__name__}.width`",
|
|
268
|
-
DeprecationWarning,
|
|
269
|
-
stacklevel=2,
|
|
270
|
-
)
|
|
271
|
-
return self.width
|
|
272
|
-
|
|
273
|
-
def _set_width(self, width: Literal["clip", "pack"] | int | tuple[Literal["relative"], int]) -> None:
|
|
274
|
-
warnings.warn(
|
|
275
|
-
f"Method `{self.__class__.__name__}._set_width` is deprecated, "
|
|
276
|
-
f"please use property `{self.__class__.__name__}.width`",
|
|
277
|
-
DeprecationWarning,
|
|
278
|
-
stacklevel=2,
|
|
279
|
-
)
|
|
280
|
-
self.width = width
|
|
281
|
-
|
|
282
246
|
def pack(
|
|
283
247
|
self,
|
|
284
248
|
size: tuple[()] | tuple[int] | tuple[int, int] = (),
|
|
@@ -339,9 +303,9 @@ class Padding(WidgetDecoration[WrappedWidget], typing.Generic[WrappedWidget]):
|
|
|
339
303
|
PaddingWarning,
|
|
340
304
|
stacklevel=3,
|
|
341
305
|
)
|
|
342
|
-
canv = self._original_widget.render((maxcol,
|
|
306
|
+
canv = self._original_widget.render((maxcol, *size[1:]), focus)
|
|
343
307
|
elif self._width_type == WHSettings.GIVEN:
|
|
344
|
-
canv = self._original_widget.render((self._width_amount,
|
|
308
|
+
canv = self._original_widget.render((self._width_amount, *size[1:]), focus)
|
|
345
309
|
else:
|
|
346
310
|
canv = self._original_widget.render((), focus)
|
|
347
311
|
|
|
@@ -439,7 +403,7 @@ class Padding(WidgetDecoration[WrappedWidget], typing.Generic[WrappedWidget]):
|
|
|
439
403
|
"""Pass keypress to self._original_widget."""
|
|
440
404
|
left, right = self.padding_values(size, True)
|
|
441
405
|
if size:
|
|
442
|
-
maxvals = (size[0] - left - right,
|
|
406
|
+
maxvals = (size[0] - left - right, *size[1:])
|
|
443
407
|
return self._original_widget.keypress(maxvals, key)
|
|
444
408
|
return self._original_widget.keypress((), key)
|
|
445
409
|
|
|
@@ -450,18 +414,17 @@ class Padding(WidgetDecoration[WrappedWidget], typing.Generic[WrappedWidget]):
|
|
|
450
414
|
|
|
451
415
|
left, right = self.padding_values(size, True)
|
|
452
416
|
if size:
|
|
453
|
-
maxvals = (size[0] - left - right,
|
|
417
|
+
maxvals = (size[0] - left - right, *size[1:])
|
|
454
418
|
if maxvals[0] == 0:
|
|
455
419
|
return None
|
|
456
420
|
else:
|
|
457
421
|
maxvals = ()
|
|
458
422
|
|
|
459
|
-
coords
|
|
460
|
-
|
|
461
|
-
return
|
|
423
|
+
if (coords := self._original_widget.get_cursor_coords(maxvals)) is not None:
|
|
424
|
+
x, y = coords
|
|
425
|
+
return x + left, y
|
|
462
426
|
|
|
463
|
-
|
|
464
|
-
return x + left, y
|
|
427
|
+
return None
|
|
465
428
|
|
|
466
429
|
def move_cursor_to_coords(
|
|
467
430
|
self,
|
|
@@ -479,7 +442,7 @@ class Padding(WidgetDecoration[WrappedWidget], typing.Generic[WrappedWidget]):
|
|
|
479
442
|
left, right = self.padding_values(size, True)
|
|
480
443
|
if size:
|
|
481
444
|
maxcol = size[0]
|
|
482
|
-
maxvals = (maxcol - left - right,
|
|
445
|
+
maxvals = (maxcol - left - right, *size[1:])
|
|
483
446
|
else:
|
|
484
447
|
maxcol = self.pack((), True)[0]
|
|
485
448
|
maxvals = ()
|
|
@@ -511,7 +474,7 @@ class Padding(WidgetDecoration[WrappedWidget], typing.Generic[WrappedWidget]):
|
|
|
511
474
|
maxcol = size[0]
|
|
512
475
|
if col < left or col >= maxcol - right:
|
|
513
476
|
return False
|
|
514
|
-
maxvals = (maxcol - left - right,
|
|
477
|
+
maxvals = (maxcol - left - right, *size[1:])
|
|
515
478
|
else:
|
|
516
479
|
maxvals = ()
|
|
517
480
|
|
|
@@ -524,7 +487,7 @@ class Padding(WidgetDecoration[WrappedWidget], typing.Generic[WrappedWidget]):
|
|
|
524
487
|
|
|
525
488
|
left, right = self.padding_values(size, True)
|
|
526
489
|
if size:
|
|
527
|
-
maxvals = (size[0] - left - right,
|
|
490
|
+
maxvals = (size[0] - left - right, *size[1:])
|
|
528
491
|
else:
|
|
529
492
|
maxvals = ()
|
|
530
493
|
|
|
@@ -558,25 +521,25 @@ def calculate_left_right_padding(
|
|
|
558
521
|
right -- a fixed number of columns to pad on the right
|
|
559
522
|
|
|
560
523
|
>>> clrp = calculate_left_right_padding
|
|
561
|
-
>>> clrp(15,
|
|
524
|
+
>>> clrp(15, "left", 0, "given", 10, None, 2, 0)
|
|
562
525
|
(2, 3)
|
|
563
|
-
>>> clrp(15,
|
|
526
|
+
>>> clrp(15, "relative", 0, "given", 10, None, 2, 0)
|
|
564
527
|
(2, 3)
|
|
565
|
-
>>> clrp(15,
|
|
528
|
+
>>> clrp(15, "relative", 100, "given", 10, None, 2, 0)
|
|
566
529
|
(5, 0)
|
|
567
|
-
>>> clrp(15,
|
|
530
|
+
>>> clrp(15, "center", 0, "given", 4, None, 2, 0)
|
|
568
531
|
(6, 5)
|
|
569
|
-
>>> clrp(15,
|
|
532
|
+
>>> clrp(15, "left", 0, "clip", 18, None, 0, 0)
|
|
570
533
|
(0, -3)
|
|
571
|
-
>>> clrp(15,
|
|
534
|
+
>>> clrp(15, "right", 0, "clip", 18, None, 0, -1)
|
|
572
535
|
(-2, -1)
|
|
573
|
-
>>> clrp(15,
|
|
536
|
+
>>> clrp(15, "center", 0, "given", 18, None, 2, 0)
|
|
574
537
|
(0, 0)
|
|
575
|
-
>>> clrp(20,
|
|
538
|
+
>>> clrp(20, "left", 0, "relative", 60, None, 0, 0)
|
|
576
539
|
(0, 8)
|
|
577
|
-
>>> clrp(20,
|
|
540
|
+
>>> clrp(20, "relative", 30, "relative", 60, None, 0, 0)
|
|
578
541
|
(2, 6)
|
|
579
|
-
>>> clrp(20,
|
|
542
|
+
>>> clrp(20, "relative", 30, "relative", 60, 14, 0, 0)
|
|
580
543
|
(2, 4)
|
|
581
544
|
"""
|
|
582
545
|
if width_type == WHSettings.RELATIVE:
|