1 """<title>Forms</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 from gui7 import ColorDialog
12 class NewDialog(gui.Dialog):
13 def __init__(self,**params):
14 title = gui.Label("New Picture...")
16 ##Once a form is created, all the widgets that are added with a name
17 ##are added to that form.
19 self.value = gui.Form()
24 t.td(gui.Label("Size"),align=0,colspan=2)
28 tt.td(gui.Label("Width: "),align=1)
29 tt.td(gui.Input(name="width",value=256,size=4))
31 tt.td(gui.Label("Height: "),align=1)
32 tt.td(gui.Input(name="height",value=256,size=4))
38 t.td(gui.Spacer(width=8,height=8))
40 t.td(gui.Label("Format",align=0))
41 t.td(gui.Label("Background",align=0))
44 g = gui.Group(name="format",value="rgb")
47 tt.td(gui.Radio(g,value="rgb"))
48 tt.td(gui.Label(" RGB"),align=-1)
50 tt.td(gui.Radio(g,value="bw"))
51 tt.td(gui.Label(" Grayscale"),align=-1)
54 g = gui.Group(name="color",value="#ffffff")
57 tt.td(gui.Radio(g,value="#000000"))
58 tt.td(gui.Label(" Black"),align=-1)
60 tt.td(gui.Radio(g,value="#ffffff"))
61 tt.td(gui.Label(" White"),align=-1)
65 radio = gui.Radio(g,value="custom")
66 color = gui.Color(default,width=40,height=16,name="custom")
67 picker = ColorDialog(default)
69 color.connect(gui.CLICK,gui.action_open,{'container':t,'window':picker})
70 picker.connect(gui.CHANGE,gui.action_setvalue,(picker,color))
78 t.td(gui.Spacer(width=8,height=8))
80 ##The okay button CLICK event is connected to the Dailog's
81 ##send event method. It will send a gui.CHANGE event.
84 e = gui.Button("Okay")
85 e.connect(gui.CLICK,self.send,gui.CHANGE)
89 e = gui.Button("Cancel")
90 e.connect(gui.CLICK,self.close,None)
93 gui.Dialog.__init__(self,title,t)
95 if __name__ == '__main__':
97 app.connect(gui.QUIT,app.quit,None)
99 c = gui.Table(width=640,height=480)
103 ##The dialog's CHANGE event is connected to this function that will display the form values.
107 for k,v in value.value.items():
111 dialog.connect(gui.CHANGE,onchange,dialog)
114 e = gui.Button("New")
115 e.connect(gui.CLICK,dialog.open,None)
121 #profile.run('app.run(c)')