File: popcorn.py

package info (click to toggle)
newt 0.21-8
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 296 kB
  • ctags: 753
  • sloc: ansic: 4,813; python: 312; makefile: 179; sh: 2
file content (66 lines) | stat: -rwxr-xr-x 1,302 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/python

from snack import *

t = Textbox(25, 1, "Some text")
li = Listbox(5, width = 20, returnExit = 1)
li.append("First", "f")
li.append("Second", "s")
li.insert("Another", "a", "f")
li.delete("a")
b = Button("Button")
e = Entry(15, "Entry")
l = Label("label")
cb = Checkbox("checkbox")
r1 = SingleRadioButton("Radio 1", None, 1)
r2 = SingleRadioButton("Radio 2", r1)

def something():
    print hello

e.setCallback(lambda: sys.exit(1))

screen = SnackScreen()

sg = Grid(2, 3)
sg.setField(b, 0, 0, anchorLeft = 1)
sg.setField(e, 1, 0, (1, 0, 0, 0), anchorLeft = 1, anchorTop = 1)
sg.setField(l, 0, 1, (0, 1, 0, 0), anchorLeft = 1)
sg.setField(cb, 1, 1, (1, 1, 0, 0), anchorLeft = 1)
sg.setField(r1, 0, 2, (0, 0, 0, 0), anchorLeft = 1)
sg.setField(r2, 1, 2, (1, 0, 0, 0), anchorLeft = 1)

g = Grid(1, 3)

g.setField(t, 0, 0)
g.setField(li, 0, 1, (0, 1, 0, 1))
g.setField(sg, 0, 2)

g.place(1, 1)

screen.gridWrappedWindow(g, "title")

f = Form()
f.add(li)
f.add(b)
f.add(e)
f.add(l)
f.add(cb)
f.add(r1)
f.add(r2)
f.add(t)

f.addHotKey("F1")

res = f.run()

screen.popWindow()

screen.finish()

print "val", e.value()
print "check", cb.value()
print "r1", r1.selected()
print "listbox", li.current()
# returns a tuple of the wrapped text, the actual width, and the actual height
print res