Advertisement
Guest User

urwid GridFlow

a guest
May 24th, 2012
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. #!/usr/bin/python3
  2. import urwid
  3.  
  4. palette = [('focus', 'white', 'black'),
  5.            ('unfocused', 'black', 'dark green')]
  6.  
  7. def do_reply(input):
  8.     if input == 'tab':
  9.         if columns.get_focus() == flow1:
  10.             columns.set_focus(flow2)
  11.         else:
  12.             columns.set_focus(flow1)
  13.  
  14. buttons = [urwid.AttrMap(urwid.Button(str(x)), 'unfocused', focus_map='focus')
  15.            for x in range(30)]
  16. flow1 = urwid.Filler(urwid.GridFlow(buttons, 10, 10, 10, 'center'))
  17. flow2 = urwid.Filler(urwid.GridFlow(buttons, 10, 10, 10, 'center'))
  18. columns = urwid.Columns([flow1, flow2])
  19. loop = urwid.MainLoop(columns, unhandled_input=do_reply, palette=palette)
  20. loop.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement