Skip to content

Instantly share code, notes, and snippets.

@vindolin
Created January 8, 2016 08:05
Show Gist options
  • Save vindolin/e309dab11cd13d632ddb to your computer and use it in GitHub Desktop.
Save vindolin/e309dab11cd13d632ddb to your computer and use it in GitHub Desktop.
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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment