Mercurial > libervia-backend
comparison frontends/wix/param.py @ 22:bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 01 Dec 2009 04:56:08 +0100 |
parents | 633c5ed65701 |
children | 925ab466c5ec |
comparison
equal
deleted
inserted
replaced
21:633c5ed65701 | 22:bb72c29f3432 |
---|---|
26 from xml.dom import minidom | 26 from xml.dom import minidom |
27 from logging import debug, info, error | 27 from logging import debug, info, error |
28 | 28 |
29 | 29 |
30 class Param(wx.Frame): | 30 class Param(wx.Frame): |
31 def __init__(self, bridge, title="Configuration"): | 31 def __init__(self, host, title="Configuration"): |
32 super(Param, self).__init__(None, title=title) | 32 super(Param, self).__init__(None, title=title) |
33 | 33 |
34 self.bridge = bridge | 34 self.host = host |
35 | 35 |
36 self.modified={} # dict of modified data (i.e. what we have to save) | 36 self.modified={} # dict of modified data (i.e. what we have to save) |
37 | 37 |
38 self.sizer = wx.BoxSizer(wx.VERTICAL) | 38 self.sizer = wx.BoxSizer(wx.VERTICAL) |
39 self.notebook=wx.Notebook(self, -1, style=wx.NB_LEFT) | 39 self.notebook=wx.Notebook(self, -1, style=wx.NB_LEFT) |
44 #events | 44 #events |
45 self.Bind(wx.EVT_CLOSE, self.onClose, self) | 45 self.Bind(wx.EVT_CLOSE, self.onClose, self) |
46 | 46 |
47 self.MakeModal() | 47 self.MakeModal() |
48 | 48 |
49 for category in self.bridge.getParamsCategories(): | 49 for category in self.host.bridge.getParamsCategories(): |
50 self.addCategory(category) | 50 self.addCategory(category) |
51 | 51 |
52 self.Show() | 52 self.Show() |
53 | 53 |
54 def addCategory(self, category): | 54 def addCategory(self, category): |
55 panel=wx.Panel(self.notebook) | 55 panel=wx.Panel(self.notebook) |
56 panel.sizer = wx.BoxSizer(wx.VERTICAL) | 56 panel.sizer = wx.BoxSizer(wx.VERTICAL) |
57 | 57 |
58 cat_dom = minidom.parseString(self.bridge.getParamsForCategory(category)) | 58 cat_dom = minidom.parseString(self.host.bridge.getParamsForCategory(category)) |
59 | 59 |
60 for param in cat_dom.documentElement.getElementsByTagName("param"): | 60 for param in cat_dom.documentElement.getElementsByTagName("param"): |
61 name = param.getAttribute("name") | 61 name = param.getAttribute("name") |
62 type = param.getAttribute("type") | 62 type = param.getAttribute("type") |
63 value = param.getAttribute("value") | 63 value = param.getAttribute("value") |
94 self.modified[event.GetEventObject().param_id]=event.GetString() | 94 self.modified[event.GetEventObject().param_id]=event.GetString() |
95 event.Skip() | 95 event.Skip() |
96 | 96 |
97 def onButtonClicked(self, event): | 97 def onButtonClicked(self, event): |
98 """Called when a paramated is modified""" | 98 """Called when a paramated is modified""" |
99 print "Button Clicked (%s/%s)" % event.GetEventObject().param_id#TODO: gof: appeler callback | 99 print "Button Clicked (%s/%s)" % event.GetEventObject().param_id |
100 #self.modified[event.GetEventObject().param_id]=event.GetString() | 100 name, category = event.GetEventObject().param_id |
101 data = {"name":name, "category":category} | |
102 id = self.host.bridge.launchAction("button", data) | |
103 self.host.current_action_ids.add(id) | |
104 print "action id:",id | |
101 event.Skip() | 105 event.Skip() |
102 | 106 |
103 def onClose(self, event): | 107 def onClose(self, event): |
104 """Close event: we have to save the params.""" | 108 """Close event: we have to save the params.""" |
105 debug("close") | 109 debug("close") |
106 #now we save the modifier params | 110 #now we save the modifier params |
107 for param in self.modified: | 111 for param in self.modified: |
108 self.bridge.setParam(param[0], self.modified[param], param[1]) | 112 self.host.bridge.setParam(param[0], self.modified[param], param[1]) |
109 | 113 |
110 self.MakeModal(False) | 114 self.MakeModal(False) |
111 event.Skip() | 115 event.Skip() |
112 | 116 |