home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 October / maximum-cd-2011-10.iso / DiscContents / digsby_setup.exe / lib / plugins / msim / myspacegui / prompts.pyo (.txt) < prev   
Encoding:
Python Compiled Bytecode  |  2011-06-22  |  3.1 KB  |  68 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. from __future__ import print_function
  5. import wx
  6. import gui.skin as skin
  7. import util.callbacks as callbacks
  8.  
  9. def AddBuddiesPrompt(callback = None):
  10.     dlg = PromptDialog('\n' + _('Would you like to automatically add your MySpace friends to your MySpace IM contact list?') + '\n', [
  11.         (_('Add Top Friends'), 'top'),
  12.         (_('Add All Friends'), 'all'),
  13.         (_('No Thanks'), 'cancel')], title = _('Add Friends'))
  14.     dlg.SetFrameIcon(skin.get('serviceicons.msim'))
  15.     dlg.Show(callback = callback)
  16.  
  17. AddBuddiesPrompt = callbacks.callsback(AddBuddiesPrompt)
  18.  
  19. class PromptDialog(wx.Dialog):
  20.     
  21.     def __init__(self, body_text, options, parent = None, id = -1, title = '', pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE, name = ''):
  22.         wx.Dialog.__init__(self, parent, id, title, pos, size, style, name)
  23.         self.construct(body_text, options)
  24.         self.Fit()
  25.  
  26.     
  27.     def construct(self, body_text, options):
  28.         self.Sizer = wx.BoxSizer(wx.VERTICAL)
  29.         self.body_text = wx.StaticText(self, -1, body_text, style = wx.ALIGN_CENTRE)
  30.         self.Sizer.Add(self.body_text, 1, wx.EXPAND | wx.LEFT | wx.RIGHT, 20)
  31.         button_sz = wx.BoxSizer(wx.HORIZONTAL)
  32.         button_sz.AddStretchSpacer()
  33.         self._buttons = { }
  34.         (ok_text, ok_value) = options.pop(0)
  35.         (cancel_text, cancel_value) = options.pop(-1)
  36.         self._buttons[wx.ID_OK] = ok_value
  37.         self._buttons[wx.ID_CANCEL] = cancel_value
  38.         ok_button = wx.Button(self, wx.ID_OK, ok_text)
  39.         cancel_button = wx.Button(self, wx.ID_CANCEL, cancel_text)
  40.         button_sz.Add(ok_button, 0, wx.ALL, border = 4)
  41.         for text, value in options:
  42.             button_id = wx.NewId()
  43.             self._buttons[button_id] = value
  44.             button = wx.Button(self, button_id, text)
  45.             button_sz.Add(button, 0, wx.ALL, border = 4)
  46.         
  47.         button_sz.Add(cancel_button, 0, wx.ALL, border = 4)
  48.         button_sz.AddStretchSpacer()
  49.         self.Sizer.Add(button_sz, 0, wx.EXPAND | wx.ALL, 4)
  50.         self.Bind(wx.EVT_BUTTON, self._on_click)
  51.  
  52.     
  53.     def _on_click(self, e):
  54.         callback = self.callback
  55.         self.callback = None
  56.         if callback is not None:
  57.             callback.success(self._buttons[e.Id])
  58.         
  59.         self.Hide()
  60.         self.Destroy()
  61.  
  62.     
  63.     def Show(self, callback = None):
  64.         self.callback = callback
  65.         return wx.Dialog.Show(self)
  66.  
  67.  
  68.