urwid 2.6.16__py3-none-any.whl → 3.0.1__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 +1 -4
- urwid/canvas.py +19 -38
- urwid/command_map.py +4 -3
- urwid/container.py +1 -1
- urwid/decoration.py +1 -1
- urwid/display/_raw_display_base.py +8 -5
- urwid/display/_win32_raw_display.py +11 -13
- urwid/display/common.py +26 -55
- urwid/display/curses.py +1 -1
- urwid/display/escape.py +6 -8
- urwid/display/lcd.py +4 -6
- urwid/display/web.py +7 -12
- urwid/event_loop/asyncio_loop.py +33 -15
- urwid/event_loop/main_loop.py +13 -18
- urwid/event_loop/tornado_loop.py +4 -5
- urwid/event_loop/trio_loop.py +1 -1
- urwid/font.py +10 -15
- urwid/signals.py +2 -1
- urwid/str_util.py +15 -18
- urwid/text_layout.py +6 -7
- urwid/util.py +6 -17
- urwid/version.py +9 -4
- urwid/vterm.py +9 -44
- urwid/widget/__init__.py +0 -6
- urwid/widget/attr_wrap.py +8 -10
- urwid/widget/bar_graph.py +2 -7
- urwid/widget/big_text.py +9 -7
- urwid/widget/box_adapter.py +4 -4
- urwid/widget/columns.py +50 -81
- urwid/widget/container.py +29 -75
- urwid/widget/edit.py +8 -8
- urwid/widget/filler.py +6 -6
- urwid/widget/frame.py +28 -37
- urwid/widget/grid_flow.py +24 -109
- urwid/widget/line_box.py +13 -0
- urwid/widget/listbox.py +12 -50
- urwid/widget/monitored_list.py +6 -4
- urwid/widget/overlay.py +4 -37
- urwid/widget/padding.py +11 -48
- urwid/widget/pile.py +177 -156
- urwid/widget/popup.py +2 -2
- urwid/widget/progress_bar.py +0 -10
- urwid/widget/scrollable.py +24 -32
- urwid/widget/treetools.py +27 -48
- urwid/widget/widget.py +7 -124
- urwid/widget/widget_decoration.py +4 -33
- urwid/wimp.py +1 -1
- {urwid-2.6.16.dist-info → urwid-3.0.1.dist-info}/METADATA +10 -15
- urwid-3.0.1.dist-info/RECORD +74 -0
- {urwid-2.6.16.dist-info → urwid-3.0.1.dist-info}/WHEEL +1 -1
- urwid-2.6.16.dist-info/RECORD +0 -74
- {urwid-2.6.16.dist-info → urwid-3.0.1.dist-info/licenses}/COPYING +0 -0
- {urwid-2.6.16.dist-info → urwid-3.0.1.dist-info}/top_level.txt +0 -0
urwid/widget/grid_flow.py
CHANGED
|
@@ -144,8 +144,9 @@ class GridFlow(WidgetWrap[Pile], WidgetContainerMixin, WidgetContainerListConten
|
|
|
144
144
|
"""
|
|
145
145
|
warnings.warn(
|
|
146
146
|
"only for backwards compatibility."
|
|
147
|
-
"You should use the new standard container property `contents` to modify GridFlow"
|
|
148
|
-
|
|
147
|
+
"You should use the new standard container property `contents` to modify GridFlow."
|
|
148
|
+
"API will be removed in version 5.0.",
|
|
149
|
+
DeprecationWarning,
|
|
149
150
|
stacklevel=2,
|
|
150
151
|
)
|
|
151
152
|
ml = MonitoredList(w for w, t in self.contents)
|
|
@@ -160,8 +161,9 @@ class GridFlow(WidgetWrap[Pile], WidgetContainerMixin, WidgetContainerListConten
|
|
|
160
161
|
def cells(self, widgets: Sequence[Widget]):
|
|
161
162
|
warnings.warn(
|
|
162
163
|
"only for backwards compatibility."
|
|
163
|
-
"You should use the new standard container property `contents` to modify GridFlow"
|
|
164
|
-
|
|
164
|
+
"You should use the new standard container property `contents` to modify GridFlow."
|
|
165
|
+
"API will be removed in version 5.0.",
|
|
166
|
+
DeprecationWarning,
|
|
165
167
|
stacklevel=2,
|
|
166
168
|
)
|
|
167
169
|
focus_position = self.focus_position
|
|
@@ -169,24 +171,6 @@ class GridFlow(WidgetWrap[Pile], WidgetContainerMixin, WidgetContainerListConten
|
|
|
169
171
|
if focus_position < len(widgets):
|
|
170
172
|
self.focus_position = focus_position
|
|
171
173
|
|
|
172
|
-
def _get_cells(self):
|
|
173
|
-
warnings.warn(
|
|
174
|
-
"only for backwards compatibility."
|
|
175
|
-
"You should use the new standard container property `contents` to modify GridFlow",
|
|
176
|
-
DeprecationWarning,
|
|
177
|
-
stacklevel=3,
|
|
178
|
-
)
|
|
179
|
-
return self.cells
|
|
180
|
-
|
|
181
|
-
def _set_cells(self, widgets: Sequence[Widget]):
|
|
182
|
-
warnings.warn(
|
|
183
|
-
"only for backwards compatibility."
|
|
184
|
-
"You should use the new standard container property `contents` to modify GridFlow",
|
|
185
|
-
DeprecationWarning,
|
|
186
|
-
stacklevel=3,
|
|
187
|
-
)
|
|
188
|
-
self.cells = widgets
|
|
189
|
-
|
|
190
174
|
@property
|
|
191
175
|
def cell_width(self) -> int:
|
|
192
176
|
"""
|
|
@@ -202,24 +186,6 @@ class GridFlow(WidgetWrap[Pile], WidgetContainerMixin, WidgetContainerListConten
|
|
|
202
186
|
self.focus_position = focus_position
|
|
203
187
|
self._cell_width = width
|
|
204
188
|
|
|
205
|
-
def _get_cell_width(self) -> int:
|
|
206
|
-
warnings.warn(
|
|
207
|
-
f"Method `{self.__class__.__name__}._get_cell_width` is deprecated, "
|
|
208
|
-
f"please use property `{self.__class__.__name__}.cell_width`",
|
|
209
|
-
DeprecationWarning,
|
|
210
|
-
stacklevel=3,
|
|
211
|
-
)
|
|
212
|
-
return self.cell_width
|
|
213
|
-
|
|
214
|
-
def _set_cell_width(self, width: int) -> None:
|
|
215
|
-
warnings.warn(
|
|
216
|
-
f"Method `{self.__class__.__name__}._set_cell_width` is deprecated, "
|
|
217
|
-
f"please use property `{self.__class__.__name__}.cell_width`",
|
|
218
|
-
DeprecationWarning,
|
|
219
|
-
stacklevel=3,
|
|
220
|
-
)
|
|
221
|
-
self.cell_width = width
|
|
222
|
-
|
|
223
189
|
@property
|
|
224
190
|
def contents(self) -> MonitoredFocusList[tuple[Widget, tuple[Literal[WHSettings.GIVEN], int]]]:
|
|
225
191
|
"""
|
|
@@ -270,8 +236,9 @@ class GridFlow(WidgetWrap[Pile], WidgetContainerMixin, WidgetContainerListConten
|
|
|
270
236
|
"""
|
|
271
237
|
warnings.warn(
|
|
272
238
|
"only for backwards compatibility."
|
|
273
|
-
"You may also use the new standard container property `focus_position` to set the focus."
|
|
274
|
-
|
|
239
|
+
"You may also use the new standard container property `focus_position` to set the focus."
|
|
240
|
+
"API will be removed in version 5.0.",
|
|
241
|
+
DeprecationWarning,
|
|
275
242
|
stacklevel=2,
|
|
276
243
|
)
|
|
277
244
|
if isinstance(cell, int):
|
|
@@ -298,17 +265,6 @@ class GridFlow(WidgetWrap[Pile], WidgetContainerMixin, WidgetContainerListConten
|
|
|
298
265
|
return None
|
|
299
266
|
return self.contents[self.focus_position][0]
|
|
300
267
|
|
|
301
|
-
def _get_focus(self) -> Widget | None:
|
|
302
|
-
warnings.warn(
|
|
303
|
-
f"method `{self.__class__.__name__}._get_focus` is deprecated, "
|
|
304
|
-
f"please use `{self.__class__.__name__}.focus` property",
|
|
305
|
-
DeprecationWarning,
|
|
306
|
-
stacklevel=3,
|
|
307
|
-
)
|
|
308
|
-
if not self.contents:
|
|
309
|
-
return None
|
|
310
|
-
return self.contents[self.focus_position][0]
|
|
311
|
-
|
|
312
268
|
def get_focus(self):
|
|
313
269
|
"""
|
|
314
270
|
Return the widget in focus, for backwards compatibility.
|
|
@@ -318,8 +274,9 @@ class GridFlow(WidgetWrap[Pile], WidgetContainerMixin, WidgetContainerListConten
|
|
|
318
274
|
"""
|
|
319
275
|
warnings.warn(
|
|
320
276
|
"only for backwards compatibility."
|
|
321
|
-
"You may also use the new standard container property `focus` to get the focus."
|
|
322
|
-
|
|
277
|
+
"You may also use the new standard container property `focus` to get the focus."
|
|
278
|
+
"API will be removed in version 5.0.",
|
|
279
|
+
DeprecationWarning,
|
|
323
280
|
stacklevel=2,
|
|
324
281
|
)
|
|
325
282
|
if not self.contents:
|
|
@@ -331,8 +288,9 @@ class GridFlow(WidgetWrap[Pile], WidgetContainerMixin, WidgetContainerListConten
|
|
|
331
288
|
warnings.warn(
|
|
332
289
|
"only for backwards compatibility."
|
|
333
290
|
"You may also use the new standard container property"
|
|
334
|
-
"`focus` to get the focus and `focus_position` to get/set the cell in focus by index"
|
|
335
|
-
|
|
291
|
+
"`focus` to get the focus and `focus_position` to get/set the cell in focus by index."
|
|
292
|
+
"API will be removed in version 5.0.",
|
|
293
|
+
DeprecationWarning,
|
|
336
294
|
stacklevel=2,
|
|
337
295
|
)
|
|
338
296
|
return self.focus
|
|
@@ -342,23 +300,10 @@ class GridFlow(WidgetWrap[Pile], WidgetContainerMixin, WidgetContainerListConten
|
|
|
342
300
|
warnings.warn(
|
|
343
301
|
"only for backwards compatibility."
|
|
344
302
|
"You may also use the new standard container property"
|
|
345
|
-
"`focus` to get the focus and `focus_position` to get/set the cell in focus by index"
|
|
346
|
-
|
|
347
|
-
stacklevel=2,
|
|
348
|
-
)
|
|
349
|
-
for i, (w, _options) in enumerate(self.contents):
|
|
350
|
-
if cell == w:
|
|
351
|
-
self.focus_position = i
|
|
352
|
-
return
|
|
353
|
-
raise ValueError(f"Widget not found in GridFlow contents: {cell!r}")
|
|
354
|
-
|
|
355
|
-
def _set_focus_cell(self, cell: Widget) -> None:
|
|
356
|
-
warnings.warn(
|
|
357
|
-
"only for backwards compatibility."
|
|
358
|
-
"You may also use the new standard container property"
|
|
359
|
-
"`focus` to get the focus and `focus_position` to get/set the cell in focus by index",
|
|
303
|
+
"`focus` to get the focus and `focus_position` to get/set the cell in focus by index."
|
|
304
|
+
"API will be removed in version 5.0.",
|
|
360
305
|
DeprecationWarning,
|
|
361
|
-
stacklevel=
|
|
306
|
+
stacklevel=2,
|
|
362
307
|
)
|
|
363
308
|
for i, (w, _options) in enumerate(self.contents):
|
|
364
309
|
if cell == w:
|
|
@@ -392,38 +337,6 @@ class GridFlow(WidgetWrap[Pile], WidgetContainerMixin, WidgetContainerListConten
|
|
|
392
337
|
) from exc
|
|
393
338
|
self.contents.focus = position
|
|
394
339
|
|
|
395
|
-
def _get_focus_position(self) -> int | None:
|
|
396
|
-
warnings.warn(
|
|
397
|
-
f"method `{self.__class__.__name__}._get_focus_position` is deprecated, "
|
|
398
|
-
f"please use `{self.__class__.__name__}.focus_position` property",
|
|
399
|
-
DeprecationWarning,
|
|
400
|
-
stacklevel=3,
|
|
401
|
-
)
|
|
402
|
-
if not self.contents:
|
|
403
|
-
raise IndexError("No focus_position, GridFlow is empty")
|
|
404
|
-
return self.contents.focus
|
|
405
|
-
|
|
406
|
-
def _set_focus_position(self, position: int) -> None:
|
|
407
|
-
"""
|
|
408
|
-
Set the widget in focus.
|
|
409
|
-
|
|
410
|
-
position -- index of child widget to be made focus
|
|
411
|
-
"""
|
|
412
|
-
warnings.warn(
|
|
413
|
-
f"method `{self.__class__.__name__}._set_focus_position` is deprecated, "
|
|
414
|
-
f"please use `{self.__class__.__name__}.focus_position` property",
|
|
415
|
-
DeprecationWarning,
|
|
416
|
-
stacklevel=3,
|
|
417
|
-
)
|
|
418
|
-
try:
|
|
419
|
-
if position < 0 or position >= len(self.contents):
|
|
420
|
-
raise IndexError(f"No GridFlow child widget at position {position}")
|
|
421
|
-
except TypeError as exc:
|
|
422
|
-
raise IndexError(f"No GridFlow child widget at position {position}").with_traceback(
|
|
423
|
-
exc.__traceback__
|
|
424
|
-
) from exc
|
|
425
|
-
self.contents.focus = position
|
|
426
|
-
|
|
427
340
|
def _get_maxcol(self, size: tuple[int] | tuple[()]) -> int:
|
|
428
341
|
if size:
|
|
429
342
|
(maxcol,) = size
|
|
@@ -540,10 +453,12 @@ class GridFlow(WidgetWrap[Pile], WidgetContainerMixin, WidgetContainerListConten
|
|
|
540
453
|
Captures focus changes.
|
|
541
454
|
"""
|
|
542
455
|
self.get_display_widget(size)
|
|
543
|
-
|
|
544
|
-
if key is None:
|
|
545
|
-
|
|
546
|
-
|
|
456
|
+
|
|
457
|
+
if (key := super().keypress(size, key)) is not None:
|
|
458
|
+
return key
|
|
459
|
+
|
|
460
|
+
self._set_focus_from_display_widget()
|
|
461
|
+
return None
|
|
547
462
|
|
|
548
463
|
def pack(
|
|
549
464
|
self,
|
urwid/widget/line_box.py
CHANGED
|
@@ -167,6 +167,19 @@ class LineBox(WidgetDecoration[WrappedWidget], delegate_to_widget_mixin("_wrappe
|
|
|
167
167
|
|
|
168
168
|
super().__init__(original_widget)
|
|
169
169
|
|
|
170
|
+
@property
|
|
171
|
+
def original_widget(self) -> WrappedWidget:
|
|
172
|
+
return super().original_widget
|
|
173
|
+
|
|
174
|
+
@original_widget.setter
|
|
175
|
+
def original_widget(self, original_widget: WrappedWidget) -> None:
|
|
176
|
+
v_index = int(bool(self.tline_widget)) # we care only about top
|
|
177
|
+
h_index = 1 # constant
|
|
178
|
+
middle: Columns = typing.cast("Columns", self._wrapped_widget[v_index])
|
|
179
|
+
_old_widget, options = middle.contents[h_index]
|
|
180
|
+
middle.contents[h_index] = (original_widget, options)
|
|
181
|
+
WidgetDecoration.original_widget.fset(self, original_widget)
|
|
182
|
+
|
|
170
183
|
@property
|
|
171
184
|
def _w(self) -> Pile:
|
|
172
185
|
return self._wrapped_widget
|
urwid/widget/listbox.py
CHANGED
|
@@ -26,8 +26,6 @@ import warnings
|
|
|
26
26
|
from collections.abc import Iterable, Sized
|
|
27
27
|
from contextlib import suppress
|
|
28
28
|
|
|
29
|
-
from typing_extensions import Protocol, runtime_checkable
|
|
30
|
-
|
|
31
29
|
from urwid import signals
|
|
32
30
|
from urwid.canvas import CanvasCombine, SolidCanvas
|
|
33
31
|
|
|
@@ -65,8 +63,8 @@ class ListWalkerError(Exception):
|
|
|
65
63
|
pass
|
|
66
64
|
|
|
67
65
|
|
|
68
|
-
@runtime_checkable
|
|
69
|
-
class ScrollSupportingBody(Protocol):
|
|
66
|
+
@typing.runtime_checkable
|
|
67
|
+
class ScrollSupportingBody(typing.Protocol):
|
|
70
68
|
"""Protocol for ListWalkers."""
|
|
71
69
|
|
|
72
70
|
def get_focus(self) -> tuple[Widget, _K]: ...
|
|
@@ -78,8 +76,8 @@ class ScrollSupportingBody(Protocol):
|
|
|
78
76
|
def get_prev(self, position: _K) -> tuple[Widget, _K] | tuple[None, None]: ...
|
|
79
77
|
|
|
80
78
|
|
|
81
|
-
@runtime_checkable
|
|
82
|
-
class EstimatedSized(Protocol):
|
|
79
|
+
@typing.runtime_checkable
|
|
80
|
+
class EstimatedSized(typing.Protocol):
|
|
83
81
|
"""Widget can estimate it's size.
|
|
84
82
|
|
|
85
83
|
PEP 424 defines API for memory-efficiency.
|
|
@@ -166,15 +164,6 @@ class SimpleListWalker(MonitoredList[_T], ListWalker):
|
|
|
166
164
|
"""
|
|
167
165
|
return self
|
|
168
166
|
|
|
169
|
-
def _get_contents(self) -> Self:
|
|
170
|
-
warnings.warn(
|
|
171
|
-
f"Method `{self.__class__.__name__}._get_contents` is deprecated, "
|
|
172
|
-
f"please use property`{self.__class__.__name__}.contents`",
|
|
173
|
-
DeprecationWarning,
|
|
174
|
-
stacklevel=3,
|
|
175
|
-
)
|
|
176
|
-
return self
|
|
177
|
-
|
|
178
167
|
def _modified(self) -> None:
|
|
179
168
|
if self.focus >= len(self):
|
|
180
169
|
self.focus = max(0, len(self) - 1)
|
|
@@ -426,24 +415,6 @@ class ListBox(Widget, WidgetContainerMixin):
|
|
|
426
415
|
self.render = nocache_widget_render_instance(self)
|
|
427
416
|
self._invalidate()
|
|
428
417
|
|
|
429
|
-
def _get_body(self):
|
|
430
|
-
warnings.warn(
|
|
431
|
-
f"Method `{self.__class__.__name__}._get_body` is deprecated, "
|
|
432
|
-
f"please use property `{self.__class__.__name__}.body`",
|
|
433
|
-
DeprecationWarning,
|
|
434
|
-
stacklevel=3,
|
|
435
|
-
)
|
|
436
|
-
return self.body
|
|
437
|
-
|
|
438
|
-
def _set_body(self, body):
|
|
439
|
-
warnings.warn(
|
|
440
|
-
f"Method `{self.__class__.__name__}._set_body` is deprecated, "
|
|
441
|
-
f"please use property `{self.__class__.__name__}.body`",
|
|
442
|
-
DeprecationWarning,
|
|
443
|
-
stacklevel=3,
|
|
444
|
-
)
|
|
445
|
-
self.body = body
|
|
446
|
-
|
|
447
418
|
@property
|
|
448
419
|
def __len__(self) -> Callable[[], int]:
|
|
449
420
|
if isinstance(self._body, Sized):
|
|
@@ -873,8 +844,9 @@ class ListBox(Widget, WidgetContainerMixin):
|
|
|
873
844
|
warnings.warn(
|
|
874
845
|
"only for backwards compatibility."
|
|
875
846
|
"You may also use the new standard container property `focus` to get the focus "
|
|
876
|
-
"and property `focus_position` to read these values."
|
|
877
|
-
|
|
847
|
+
"and property `focus_position` to read these values."
|
|
848
|
+
"API will be removed in version 5.0.",
|
|
849
|
+
DeprecationWarning,
|
|
878
850
|
stacklevel=2,
|
|
879
851
|
)
|
|
880
852
|
return self._body.get_focus()
|
|
@@ -888,15 +860,6 @@ class ListBox(Widget, WidgetContainerMixin):
|
|
|
888
860
|
"""
|
|
889
861
|
return self._body.get_focus()[0]
|
|
890
862
|
|
|
891
|
-
def _get_focus(self) -> Widget:
|
|
892
|
-
warnings.warn(
|
|
893
|
-
f"method `{self.__class__.__name__}._get_focus` is deprecated, "
|
|
894
|
-
f"please use `{self.__class__.__name__}.focus` property",
|
|
895
|
-
DeprecationWarning,
|
|
896
|
-
stacklevel=3,
|
|
897
|
-
)
|
|
898
|
-
return self.focus
|
|
899
|
-
|
|
900
863
|
def _get_focus_position(self):
|
|
901
864
|
"""
|
|
902
865
|
Return the list walker position of the widget in focus. The type
|
|
@@ -1938,8 +1901,7 @@ class ListBox(Widget, WidgetContainerMixin):
|
|
|
1938
1901
|
)
|
|
1939
1902
|
return False
|
|
1940
1903
|
|
|
1941
|
-
|
|
1942
|
-
if handled:
|
|
1904
|
+
if w.mouse_event((maxcol,), event, button, col, row - wrow, focus):
|
|
1943
1905
|
return True
|
|
1944
1906
|
|
|
1945
1907
|
if is_mouse_press(event):
|
|
@@ -1995,8 +1957,8 @@ class ListBox(Widget, WidgetContainerMixin):
|
|
|
1995
1957
|
the focus up to the top. This is the best we can do with
|
|
1996
1958
|
a minimal list walker implementation.
|
|
1997
1959
|
"""
|
|
1998
|
-
|
|
1999
|
-
if positions_fn:
|
|
1960
|
+
|
|
1961
|
+
if positions_fn := getattr(self._body, "positions", None):
|
|
2000
1962
|
yield from positions_fn()
|
|
2001
1963
|
return
|
|
2002
1964
|
|
|
@@ -2026,8 +1988,8 @@ class ListBox(Widget, WidgetContainerMixin):
|
|
|
2026
1988
|
reverse of what `__iter__()` produces, but this is the best we can
|
|
2027
1989
|
do with a minimal list walker implementation.
|
|
2028
1990
|
"""
|
|
2029
|
-
|
|
2030
|
-
if positions_fn:
|
|
1991
|
+
|
|
1992
|
+
if positions_fn := getattr(self._body, "positions", None):
|
|
2031
1993
|
yield from positions_fn(reverse=True)
|
|
2032
1994
|
return
|
|
2033
1995
|
|
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.
|
|
@@ -245,7 +245,8 @@ class MonitoredFocusList(MonitoredList[_T], typing.Generic[_T]):
|
|
|
245
245
|
def _get_focus(self) -> int | None:
|
|
246
246
|
warnings.warn(
|
|
247
247
|
f"method `{self.__class__.__name__}._get_focus` is deprecated, "
|
|
248
|
-
f"please use `{self.__class__.__name__}.focus` property"
|
|
248
|
+
f"please use `{self.__class__.__name__}.focus` property."
|
|
249
|
+
"API will be removed in version 4.0.",
|
|
249
250
|
DeprecationWarning,
|
|
250
251
|
stacklevel=3,
|
|
251
252
|
)
|
|
@@ -254,7 +255,8 @@ class MonitoredFocusList(MonitoredList[_T], typing.Generic[_T]):
|
|
|
254
255
|
def _set_focus(self, index: int) -> None:
|
|
255
256
|
warnings.warn(
|
|
256
257
|
f"method `{self.__class__.__name__}._set_focus` is deprecated, "
|
|
257
|
-
f"please use `{self.__class__.__name__}.focus` property"
|
|
258
|
+
f"please use `{self.__class__.__name__}.focus` property."
|
|
259
|
+
"API will be removed in version 4.0.",
|
|
258
260
|
DeprecationWarning,
|
|
259
261
|
stacklevel=3,
|
|
260
262
|
)
|
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
|
@@ -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
|
|