1 """<title>Custom Actions</title>"""
3 from pygame.locals import *
5 # the following line is not needed if pgu is installed
6 import sys; sys.path.insert(0, "..")
10 class ColorDialog(gui.Dialog):
11 def __init__(self,value,**params):
12 self.value = list(gui.parse_color(value))
14 title = gui.Label("Color Picker")
20 self.color = gui.Color(self.value,width=64,height=64)
21 main.td(self.color,rowspan=3,colspan=1)
23 ##The sliders CHANGE events are connected to the adjust method. The
24 ##adjust method updates the proper color component based on the value
25 ##passed to the method.
27 main.td(gui.Label(' Red: '),1,0)
28 e = gui.HSlider(value=self.value[0],min=0,max=255,size=32,width=128,height=16)
29 e.connect(gui.CHANGE,self.adjust,(0,e))
33 main.td(gui.Label(' Green: '),1,1)
34 e = gui.HSlider(value=self.value[1],min=0,max=255,size=32,width=128,height=16)
35 e.connect(gui.CHANGE,self.adjust,(1,e))
38 main.td(gui.Label(' Blue: '),1,2)
39 e = gui.HSlider(value=self.value[2],min=0,max=255,size=32,width=128,height=16)
40 e.connect(gui.CHANGE,self.adjust,(2,e))
43 gui.Dialog.__init__(self,title,main)
45 ##The custom adjust handler.
47 def adjust(self,value):
49 self.value[num] = slider.value
54 if __name__ == '__main__':
56 app.connect(gui.QUIT,app.quit,None)
58 c = gui.Table(width=640,height=480)
60 dialog = ColorDialog("#00ffff")
62 e = gui.Button("Color")
63 e.connect(gui.CLICK,dialog.open,None)