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

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import wx
  5.  
  6. def CopyToClipboard(s):
  7.     if not s:
  8.         return None
  9.     
  10.     if not isinstance(s, basestring):
  11.         raise TypeError
  12.     
  13.     clip = wx.TheClipboard
  14.     if clip.Open():
  15.         
  16.         try:
  17.             clip.SetData(wx.TextDataObject(s))
  18.             return True
  19.         finally:
  20.             clip.Close()
  21.  
  22.     
  23.     return False
  24.  
  25. copy = CopyToClipboard
  26. _clipboard_types = {
  27.     wx.DF_BITMAP: (wx.BitmapDataObject, 'Bitmap'),
  28.     wx.DF_TEXT: (wx.TextDataObject, 'Text') }
  29.  
  30. def clipboard_get(df_type):
  31.     df = wx.DataFormat(df_type)
  32.     clip = wx.TheClipboard
  33.     if clip.Open():
  34.         
  35.         try:
  36.             if clip.IsSupported(df):
  37.                 (obj_type, obj_attr) = _clipboard_types[df_type]
  38.                 obj = obj_type()
  39.                 clip.GetData(obj)
  40.                 return getattr(obj, obj_attr)
  41.         finally:
  42.             clip.Close()
  43.  
  44.     
  45.  
  46.  
  47. def get_bitmap():
  48.     return clipboard_get(wx.DF_BITMAP)
  49.  
  50.  
  51. def get_text():
  52.     return clipboard_get(wx.DF_TEXT)
  53.  
  54.