added action cb mechanism for buttons. Tested with a temporary new user registration button.
This commit is contained in:
parent
bd70d6d7b6
commit
a103e8b41b
2 changed files with 226 additions and 66 deletions
|
|
@ -284,11 +284,46 @@ class MainWindow(wx.Frame, QuickApp):
|
|||
answer = wx.ID_NO
|
||||
if answer==wx.ID_NO:
|
||||
self.bridge.confirmationAnswer(id, False, answer_data)
|
||||
|
||||
dlg.Destroy()
|
||||
|
||||
elif type == "YES/NO":
|
||||
debug ("Yes/No confirmation asked")
|
||||
dlg = wx.MessageDialog(self, data["message"],
|
||||
'Confirmation',
|
||||
wx.YES_NO | wx.ICON_QUESTION
|
||||
)
|
||||
answer=dlg.ShowModal()
|
||||
if answer==wx.ID_YES:
|
||||
self.bridge.confirmationAnswer(id, True, {})
|
||||
if answer==wx.ID_NO:
|
||||
self.bridge.confirmationAnswer(id, False, {})
|
||||
|
||||
dlg.Destroy()
|
||||
|
||||
|
||||
|
||||
def actionResult(self, type, id, data):
|
||||
debug ("actionResult: type = [%s] id = [%s] data =[%s]" % (type, id, data))
|
||||
if type == "SUPPRESS":
|
||||
self.current_action_ids.remove(id)
|
||||
elif type == "SUCCESS":
|
||||
dlg = wx.MessageDialog(self, data["message"],
|
||||
'Success',
|
||||
wx.OK | wx.ICON_INFORMATION
|
||||
)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
elif type == "ERROR":
|
||||
dlg = wx.MessageDialog(self, data["message"],
|
||||
'Error',
|
||||
wx.OK | wx.ICON_ERROR
|
||||
)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
else:
|
||||
error ("FIXME FIXME FIXME: type [%s] not implemented" % type)
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
|
||||
def progressCB(self, id, title, message):
|
||||
data = self.bridge.getProgress(id)
|
||||
|
|
@ -340,7 +375,7 @@ class MainWindow(wx.Frame, QuickApp):
|
|||
|
||||
def onParam(self, e):
|
||||
debug("Param request")
|
||||
param=Param(self.bridge)
|
||||
param=Param(self)
|
||||
|
||||
def onExit(self, e):
|
||||
self.Close()
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@ from logging import debug, info, error
|
|||
|
||||
|
||||
class Param(wx.Frame):
|
||||
def __init__(self, bridge, title="Configuration"):
|
||||
def __init__(self, host, title="Configuration"):
|
||||
super(Param, self).__init__(None, title=title)
|
||||
|
||||
self.bridge = bridge
|
||||
self.host = host
|
||||
|
||||
self.modified={} # dict of modified data (i.e. what we have to save)
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ class Param(wx.Frame):
|
|||
|
||||
self.MakeModal()
|
||||
|
||||
for category in self.bridge.getParamsCategories():
|
||||
for category in self.host.bridge.getParamsCategories():
|
||||
self.addCategory(category)
|
||||
|
||||
self.Show()
|
||||
|
|
@ -55,7 +55,7 @@ class Param(wx.Frame):
|
|||
panel=wx.Panel(self.notebook)
|
||||
panel.sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
|
||||
cat_dom = minidom.parseString(self.bridge.getParamsForCategory(category))
|
||||
cat_dom = minidom.parseString(self.host.bridge.getParamsForCategory(category))
|
||||
|
||||
for param in cat_dom.documentElement.getElementsByTagName("param"):
|
||||
name = param.getAttribute("name")
|
||||
|
|
@ -96,8 +96,12 @@ class Param(wx.Frame):
|
|||
|
||||
def onButtonClicked(self, event):
|
||||
"""Called when a paramated is modified"""
|
||||
print "Button Clicked (%s/%s)" % event.GetEventObject().param_id#TODO: gof: appeler callback
|
||||
#self.modified[event.GetEventObject().param_id]=event.GetString()
|
||||
print "Button Clicked (%s/%s)" % event.GetEventObject().param_id
|
||||
name, category = event.GetEventObject().param_id
|
||||
data = {"name":name, "category":category}
|
||||
id = self.host.bridge.launchAction("button", data)
|
||||
self.host.current_action_ids.add(id)
|
||||
print "action id:",id
|
||||
event.Skip()
|
||||
|
||||
def onClose(self, event):
|
||||
|
|
@ -105,7 +109,7 @@ class Param(wx.Frame):
|
|||
debug("close")
|
||||
#now we save the modifier params
|
||||
for param in self.modified:
|
||||
self.bridge.setParam(param[0], self.modified[param], param[1])
|
||||
self.host.bridge.setParam(param[0], self.modified[param], param[1])
|
||||
|
||||
self.MakeModal(False)
|
||||
event.Skip()
|
||||
|
|
|
|||
Loading…
Reference in a new issue