~yacinechaouche/+junk/BZR

« back to all changes in this revision

Viewing changes to CODE/TEST/PYTHON/scrollablelist.py

  • Committer: yacinechaouche at yahoo
  • Date: 2015-01-14 22:23:03 UTC
  • Revision ID: yacinechaouche@yahoo.com-20150114222303-6gbtqqxii717vyka
Ajout de CODE et PROD. Il faudra ensuite ajouter ce qu'il y avait dan TMP

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import urwid
 
2
 
 
3
palette = [('header', 'white', 'black'),
 
4
    ('reveal focus', 'black', 'dark cyan', 'standout'),]
 
5
content = urwid.SimpleListWalker([
 
6
    urwid.AttrMap(w, None, 'reveal focus') for w in [
 
7
    urwid.Text("This is a text string that is fairly long"),
 
8
    urwid.Divider("-"),
 
9
    urwid.Text("Short one"),
 
10
    urwid.Text("Another"),
 
11
    urwid.Divider("-"),
 
12
    urwid.Text("What could be after this?"),
 
13
    urwid.Text("The end."),]])
 
14
listbox = urwid.ListBox(content)
 
15
show_key = urwid.Text("", wrap='clip')
 
16
head = urwid.AttrMap(show_key, 'header')
 
17
top = urwid.Frame(listbox, head)
 
18
 
 
19
def show_all_input(input, raw):
 
20
    show_key.set_text("Pressed: " + " ".join([
 
21
        unicode(i) for i in input]))
 
22
    return input
 
23
 
 
24
def exit_on_cr(input):
 
25
    if input == 'enter':
 
26
        raise urwid.ExitMainLoop()
 
27
 
 
28
loop = urwid.MainLoop(top, palette,
 
29
    input_filter=show_all_input, unhandled_input=exit_on_cr)
 
30
loop.run()