comparison frontends/wix/main_window.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 6928e3cb73a8
children 925ab466c5ec
comparison
equal deleted inserted replaced
21:633c5ed65701 22:bb72c29f3432
282 self.waitProgress(id, "File Transfer", "Copying %s" % os.path.basename(filename)) 282 self.waitProgress(id, "File Transfer", "Copying %s" % os.path.basename(filename))
283 else: 283 else:
284 answer = wx.ID_NO 284 answer = wx.ID_NO
285 if answer==wx.ID_NO: 285 if answer==wx.ID_NO:
286 self.bridge.confirmationAnswer(id, False, answer_data) 286 self.bridge.confirmationAnswer(id, False, answer_data)
287 287
288 dlg.Destroy() 288 dlg.Destroy()
289 289
290 290 elif type == "YES/NO":
291 291 debug ("Yes/No confirmation asked")
292 dlg = wx.MessageDialog(self, data["message"],
293 'Confirmation',
294 wx.YES_NO | wx.ICON_QUESTION
295 )
296 answer=dlg.ShowModal()
297 if answer==wx.ID_YES:
298 self.bridge.confirmationAnswer(id, True, {})
299 if answer==wx.ID_NO:
300 self.bridge.confirmationAnswer(id, False, {})
301
302 dlg.Destroy()
303
304 def actionResult(self, type, id, data):
305 debug ("actionResult: type = [%s] id = [%s] data =[%s]" % (type, id, data))
306 if type == "SUPPRESS":
307 self.current_action_ids.remove(id)
308 elif type == "SUCCESS":
309 dlg = wx.MessageDialog(self, data["message"],
310 'Success',
311 wx.OK | wx.ICON_INFORMATION
312 )
313 dlg.ShowModal()
314 dlg.Destroy()
315 elif type == "ERROR":
316 dlg = wx.MessageDialog(self, data["message"],
317 'Error',
318 wx.OK | wx.ICON_ERROR
319 )
320 dlg.ShowModal()
321 dlg.Destroy()
322 else:
323 error ("FIXME FIXME FIXME: type [%s] not implemented" % type)
324 raise NotImplementedError
325
326
292 327
293 def progressCB(self, id, title, message): 328 def progressCB(self, id, title, message):
294 data = self.bridge.getProgress(id) 329 data = self.bridge.getProgress(id)
295 if data: 330 if data:
296 if not data['position']: 331 if not data['position']:
338 debug("Status change request") 373 debug("Status change request")
339 self.__updateStatus() 374 self.__updateStatus()
340 375
341 def onParam(self, e): 376 def onParam(self, e):
342 debug("Param request") 377 debug("Param request")
343 param=Param(self.bridge) 378 param=Param(self)
344 379
345 def onExit(self, e): 380 def onExit(self, e):
346 self.Close() 381 self.Close()
347 382
348 def onAddContact(self, e): 383 def onAddContact(self, e):