Commit before breaking everything
[matches/honours.git] / research / transmission_spectroscopy / simulator / pgu-0.18 / examples / gui11.py
1 import sys
2 sys.path.insert(0, '..')
3
4
5 import pygame
6 from pygame.locals import *
7 from pgu import gui
8
9
10 _count = 1 # for added items
11
12
13 def clear_list(arg):
14     my_list.clear()
15     my_list.resize()
16     my_list.repaint()
17
18 def remove_list_item(arg):
19     v = my_list.value
20     if v:
21         item = v
22         my_list.remove(item)
23         my_list.resize()
24         my_list.repaint()
25
26 def add_list_item(arg):
27     global _count
28     my_list.add("item "+str(_count),value=_count)
29     my_list.resize()
30     my_list.repaint()
31     _count += 1
32
33
34
35 #theme = gui.Theme('../data/themes/default')
36 app = gui.Desktop()
37 app.connect(gui.QUIT,app.quit,None)
38
39 main = gui.Container(width=500, height=400) #, background=(220, 220, 220) )
40
41
42 main.add(gui.Label("List Example", cls="h1"), 20, 20)
43
44
45
46 my_list = gui.List(width=150, height=100)
47 main.add(my_list, 250, 100)
48
49
50 b = gui.Button("add item", width=150)
51 main.add(b, 40, 110)
52 b.connect(gui.CLICK, add_list_item, None)
53
54 b = gui.Button("remove selected", width=150)
55 main.add(b, 40, 140)
56 b.connect(gui.CLICK, remove_list_item, None)
57
58 b = gui.Button("clear", width=150)
59 main.add(b, 40, 170)
60 b.connect(gui.CLICK, clear_list, None)
61
62
63
64
65
66 app.run(main)

UCC git Repository :: git.ucc.asn.au