comparison frontends/wix/main_window.py @ 182:556c2bd7c344

Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
author Goffi <goffi@goffi.org>
date Wed, 18 Aug 2010 12:45:48 +0800
parents fdb961f27ae9
children 9ee4a1d0d7fb
comparison
equal deleted inserted replaced
181:a566f654929e 182:556c2bd7c344
204 x=(wx.DisplaySize()[0]-popup.GetSize()[0])/2 204 x=(wx.DisplaySize()[0]-popup.GetSize()[0])/2
205 popup.SetPosition((x,0)) 205 popup.SetPosition((x,0))
206 popup.Show() 206 popup.Show()
207 wx.CallLater(5000,popup.Destroy) 207 wx.CallLater(5000,popup.Destroy)
208 208
209 def showDialog(self, message, title="", type="info"): 209 def showDialog(self, message, title="", type="info", answer_cb = None, answer_data = None):
210 if type == 'info': 210 if type == 'info':
211 flags = wx.OK | wx.ICON_INFORMATION 211 flags = wx.OK | wx.ICON_INFORMATION
212 elif type == 'error': 212 elif type == 'error':
213 flags = wx.OK | wx.ICON_ERROR 213 flags = wx.OK | wx.ICON_ERROR
214 elif type == 'yes/no': 214 elif type == 'yes/no':
217 flags = wx.OK | wx.ICON_INFORMATION 217 flags = wx.OK | wx.ICON_INFORMATION
218 error(_('unmanaged dialog type: %s'), type) 218 error(_('unmanaged dialog type: %s'), type)
219 dlg = wx.MessageDialog(self, message, title, flags) 219 dlg = wx.MessageDialog(self, message, title, flags)
220 answer = dlg.ShowModal() 220 answer = dlg.ShowModal()
221 dlg.Destroy() 221 dlg.Destroy()
222 return True if (answer == wx.ID_YES or answer == wx.ID_OK) else False 222 if answer_cb:
223 data = [answer_data] if answer_data else []
224 answer_cb(True if (answer == wx.ID_YES or answer == wx.ID_OK) else False, *data)
223 225
224 def setStatusOnline(self, online=True): 226 def setStatusOnline(self, online=True):
225 """enable/disable controls, must be called when local user online status change""" 227 """enable/disable controls, must be called when local user online status change"""
226 if online: 228 if online:
227 self.SetStatusText(msgONLINE) 229 self.SetStatusText(msgONLINE)