home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 June / maximum-cd-2009-06.iso / DiscContents / digsby_setup.exe / lib / gui / imagedialog.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-02-26  |  2.4 KB  |  57 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. from PIL.Image import BICUBIC, ANTIALIAS
  5. import wx
  6.  
  7. HSizer = lambda : wx.BoxSizer(wx.HORIZONTAL)
  8.  
  9. VSizer = lambda : wx.BoxSizer(wx.VERTICAL)
  10.  
  11. class ImageDialog(wx.Dialog):
  12.     SuccessID = wx.ID_OK
  13.     
  14.     def __init__(self, parent, screenshot, pos, title, message, oklabel = _('OK'), cancellabel = _('Cancel')):
  15.         wx.Dialog.__init__(self, parent, -1, title)
  16.         if isinstance(screenshot, wx.Bitmap):
  17.             screenshot = screenshot.PIL
  18.         
  19.         (w, h) = screenshot.size
  20.         squaresize = 650
  21.         img = screenshot
  22.         if w > squaresize or h > squaresize:
  23.             if w > h:
  24.                 new_height = int((h / float(w)) * squaresize)
  25.                 img = None(img.resize, (squaresize, new_height) if squaresize > w else ANTIALIAS)
  26.             else:
  27.                 new_width = int((w / float(h)) * squaresize)
  28.                 img = None(img.resize, (new_width, squaresize) if squaresize > h else ANTIALIAS)
  29.         
  30.         self.screenshot = img.WXB
  31.         p = self.panel = wx.Panel(self)
  32.         s = self.panel.Sizer = VSizer()
  33.         s.Add((self.screenshot.Width, self.screenshot.Height + 20))
  34.         p.Bind(wx.EVT_PAINT, self.paint)
  35.         s.Add(wx.StaticText(p, -1, message), 0, wx.EXPAND | wx.BOTTOM, 8)
  36.         send = wx.Button(p, self.SuccessID, oklabel)
  37.         send.SetDefault()
  38.         cancel = wx.Button(p, wx.ID_CANCEL, cancellabel)
  39.         h = HSizer()
  40.         h.AddStretchSpacer(1)
  41.         h.AddMany([
  42.             (send, 0, wx.EXPAND | wx.RIGHT, 10),
  43.             (cancel, 0)])
  44.         s.Add(h, 0, wx.EXPAND)
  45.         s = self.Sizer = VSizer()
  46.         s.Add(self.panel, 1, wx.EXPAND | wx.ALL, 8)
  47.         self.Fit()
  48.         self.SetPosition(pos)
  49.  
  50.     
  51.     def paint(self, e):
  52.         dc = wx.PaintDC(e.EventObject)
  53.         r = self.ClientRect
  54.         dc.DrawBitmap(self.screenshot, r.HCenter(self.screenshot), 10, True)
  55.  
  56.  
  57.