]> git.ipfire.org Git - thirdparty/newt.git/blob - peanuts.py
install python modules to purelib and platlib
[thirdparty/newt.git] / peanuts.py
1 #!/usr/bin/python
2
3 # Demo program to show use of python-newt module
4
5 from __future__ import absolute_import, print_function, unicode_literals
6 from snack import *
7
8 screen = SnackScreen()
9
10 li = Listbox(height = 3, width = 20, returnExit = 1)
11 li.append("First", 1)
12 li.append("Second", 2)
13 li.append("Third", 3)
14 rb = RadioBar(screen, (("This", "this", 0),
15 ("Default", "default", 1),
16 ("That", "that", 0)))
17 bb = ButtonBar(screen, (("Ok", "ok"), ("Cancel", "cancel")))
18
19 ct = CheckboxTree(height = 5, scroll = 1)
20 ct.append("Colors")
21 ct.addItem("Red", (0, snackArgs['append']))
22 ct.addItem("Yellow", (0, snackArgs['append']))
23 ct.addItem("Blue", (0, snackArgs['append']))
24 ct.append("Flavors")
25 ct.append("Numbers")
26 ct.addItem("1", (2, snackArgs['append']))
27 ct.addItem("2", (2, snackArgs['append']))
28 ct.addItem("3", (2, snackArgs['append']))
29 ct.append("Names")
30 ct.append("Months")
31 ct.append("Events")
32 g = GridForm(screen, "My Test", 1, 4)
33 g.add(li, 0, 0)
34 g.add(rb, 0, 1, (0, 1, 0, 1))
35 g.add(ct, 0, 2)
36 g.add(bb, 0, 3, growx = 1)
37
38 result = g.runOnce()
39
40 screen.finish()
41
42 print(result)
43 print("listbox:", li.current())
44 print("rb:", rb.getSelection())
45 print("bb:", bb.buttonPressed(result))
46 print("checkboxtree:", ct.getSelection())