1 """<title>an example of a custom html dialog with python connections</title>"""
3 from pygame.locals import *
5 # the following line is not needed if pgu is installed
6 import sys; sys.path.insert(0, "..")
11 from gui7 import ColorDialog
13 class NewDialog(gui.Dialog):
14 def __init__(self,**params):
15 title = gui.Label("New Picture...")
17 ##Note how the global variables are set for the scripting of HTML
19 picker = ColorDialog("#ffffff")
20 doc = html.HTML(globals={'gui':gui,'dialog':self,'picker':picker},data="""
25 <tr><td colspan='2' align='center'>
27 <tr><td colspan='2' align='center'>
29 <tr><td align=right>Width: <td><input type='text' size='4' value='256' name='width'>
30 <tr><td align=right>Height: <td><input type='text' size='4' value='256' name='height'>
33 <tr><td>Format<td>Background
36 <input type='radio' name='format' value='rgb' checked> RGB<br>
37 <input type='radio' name='format' value='bw'> Grayscale
39 <input type='radio' name='background' value='#000000'> Black<br>
40 <input type='radio' name='background' value='#ffffff' checked> White<br>
41 <input type='radio' name='background' value='custom'> <object type='gui.Color' width=48 height=16 value='#ffffff' name='custom' border=1 onclick='picker.open()'>
43 <tr><td colspan=2><input type='button' value='Okay' onclick='dialog.send(gui.CHANGE)'> <input type='button' value='Cancel' onclick='dialog.close()'>
48 gui.Dialog.__init__(self,title,doc)
50 picker.connect(gui.CHANGE,gui.action_setvalue,(picker,doc['form']['custom']))
53 self.value = doc['form']
57 if __name__ == '__main__':
59 app.connect(gui.QUIT,app.quit,None)
61 c = gui.Table(width=640,height=480)
65 ##The dialog's CHANGE event is connected to this function that will display the form values.
69 for k,v in value.value.items():
73 dialog.connect(gui.CHANGE,onchange,dialog)
77 e.connect(gui.CLICK,dialog.open,None)
83 #profile.run('app.run(c)')