Thomas Schüßler
2016-01-08 08:08:30 UTC
How can I keep a column packed when its content changes?
The text in the left column in my example wraps when it's content grows
in length.
https://gist.github.com/vindolin/e309dab11cd13d632ddb
import urwid
class MyEdit(urwid.Edit):
def keypress(self, size, key):
if key == 'enter':
return True
urwid.Edit.keypress(self, size, key)
edit = MyEdit(edit_text='Press ENTER to see my problem!')
left = urwid.Text('left left left')
right = urwid.Text('right right right')
header = urwid.Columns([
('pack', urwid.AttrMap(left, 'left')),
urwid.AttrMap(edit, 'center'),
('pack', urwid.AttrMap(right, 'right')),
], dividechars=1)
frame = urwid.Frame(body=urwid.ListBox([]), header=header)
def unhandled_input(input_):
left.set_text('This does not fit into the left column :(, how can I
keep it packed?')
palette = [
('left', '', '', '', '', '#600'),
('center', '', '', '', '', '#006'),
('right', '', '', '', '', '#060'),
]
frame.set_focus('header')
loop = urwid.MainLoop(frame, palette, unhandled_input=unhandled_input)
loop.screen.set_terminal_properties(colors=256)
loop.run()
The text in the left column in my example wraps when it's content grows
in length.
https://gist.github.com/vindolin/e309dab11cd13d632ddb
import urwid
class MyEdit(urwid.Edit):
def keypress(self, size, key):
if key == 'enter':
return True
urwid.Edit.keypress(self, size, key)
edit = MyEdit(edit_text='Press ENTER to see my problem!')
left = urwid.Text('left left left')
right = urwid.Text('right right right')
header = urwid.Columns([
('pack', urwid.AttrMap(left, 'left')),
urwid.AttrMap(edit, 'center'),
('pack', urwid.AttrMap(right, 'right')),
], dividechars=1)
frame = urwid.Frame(body=urwid.ListBox([]), header=header)
def unhandled_input(input_):
left.set_text('This does not fit into the left column :(, how can I
keep it packed?')
palette = [
('left', '', '', '', '', '#600'),
('center', '', '', '', '', '#006'),
('right', '', '', '', '', '#060'),
]
frame.set_focus('header')
loop = urwid.MainLoop(frame, palette, unhandled_input=unhandled_input)
loop.screen.set_terminal_properties(colors=256)
loop.run()
--
You received this message because you are subscribed to the Google Groups "Urwid Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to urwid+***@excess.org.
To post to this group, send email to ***@excess.org.
For more options, visit https://groups.google.com/a/excess.org/d/optout.
You received this message because you are subscribed to the Google Groups "Urwid Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to urwid+***@excess.org.
To post to this group, send email to ***@excess.org.
For more options, visit https://groups.google.com/a/excess.org/d/optout.