Fix urwid > 2.4.2 compatibility
1. `Columns` widget use FIXED pack method for items if they declare sizing as fixed. 2. `Columns` are implicitly declared as FIXED if all contents sizes are known or can be calculated without external size information. 3. `Text` is explicitly FIXED and FLOW widget (widget knows its size from contents). Fix: explicit declare that widgets are FLOW-only Change-Id: Ic0de5957ed47fadf2f0f02b235178eb03ecd1b04
This commit is contained in:
parent
346804a832
commit
c9b58583d2
@ -62,6 +62,10 @@ class FixedRadioButton(urwid.RadioButton):
|
|||||||
return (len(self.get_label())+4, 1)
|
return (len(self.get_label())+4, 1)
|
||||||
|
|
||||||
class TableColumn(urwid.Pile):
|
class TableColumn(urwid.Pile):
|
||||||
|
def sizing(self):
|
||||||
|
"""Explicit declare flow sizing due to the custom pack method."""
|
||||||
|
return frozenset((urwid.FLOW,))
|
||||||
|
|
||||||
def pack(self, size, focus=False):
|
def pack(self, size, focus=False):
|
||||||
maxcol = size[0]
|
maxcol = size[0]
|
||||||
mx = max([i[0].pack((maxcol,), focus)[0] for i in self.contents])
|
mx = max([i[0].pack((maxcol,), focus)[0] for i in self.contents])
|
||||||
@ -104,7 +108,6 @@ class MyEdit(urwid.Edit):
|
|||||||
super(MyEdit, self).__init__(*args, **kw)
|
super(MyEdit, self).__init__(*args, **kw)
|
||||||
|
|
||||||
def keypress(self, size, key):
|
def keypress(self, size, key):
|
||||||
(maxcol,) = size
|
|
||||||
if self._command_map[key] == keymap.YANK:
|
if self._command_map[key] == keymap.YANK:
|
||||||
text = self.ring.yank()
|
text = self.ring.yank()
|
||||||
if text:
|
if text:
|
||||||
@ -349,6 +352,13 @@ class Searchable(object):
|
|||||||
class HyperText(urwid.Text):
|
class HyperText(urwid.Text):
|
||||||
_selectable = True
|
_selectable = True
|
||||||
|
|
||||||
|
def sizing(self):
|
||||||
|
"""Explicit declare flow sizing due to the custom pack method.
|
||||||
|
|
||||||
|
Normal Text can be rendered as FIXED.
|
||||||
|
"""
|
||||||
|
return frozenset((urwid.FLOW,))
|
||||||
|
|
||||||
def __init__(self, markup, align=urwid.LEFT, wrap=urwid.SPACE, layout=None):
|
def __init__(self, markup, align=urwid.LEFT, wrap=urwid.SPACE, layout=None):
|
||||||
self._mouse_press_item = None
|
self._mouse_press_item = None
|
||||||
self.selectable_items = []
|
self.selectable_items = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user