parameters: (win, filename)
docstring: WindowToFile: save part of the screen as 'filename'.
docstring_summary: WindowToFile: save part of the screen as 'filename'.
docstring_tokens: WindowToFile : save part of the screen as filename .
function: def WTF(win, filename):
      """WindowToFile: save part of the screen as 'filename'."""
      if wx.Platform == '__WXMAC__':
          # Blit does not write color
          os.system('screencapture scr.png')
          screen = wx.Bitmap('scr.png')
          rect = win.GetRect()
          bitmap = screen.GetSubBitmap(rect)
      else:
          context = wx.ScreenDC()
          memory = wx.MemoryDC()
          x,y = win.GetPosition()
          w,h = win.GetSize()
          x0,y0 = win.ClientToScreen((0,0))
          h += y0 - y + 5
          w += 10
          bitmap = wx.EmptyBitmap(w, h, -1)
          memory.SelectObject(bitmap)
          memory.Blit(0, 0, w, h, context, x, y)
          memory.Destroy()
          context.Destroy()
      print 'Saving bitmap ', filename
      bitmap.SaveFile(filename, wx.BITMAP_TYPE_PNG)
      bitmap.Destroy()
function_tokens: def WTF ( win , filename ) : if wx . Platform == '__WXMAC__' : # Blit does not write color os . system ( 'screencapture scr.png' ) screen = wx . Bitmap ( 'scr.png' ) rect = win . GetRect ( ) bitmap = screen . GetSubBitmap ( rect ) else : context = wx . ScreenDC ( ) memory = wx . MemoryDC ( ) x , y = win . GetPosition ( ) w , h = win . GetSize ( ) x0 , y0 = win . ClientToScreen ( ( 0 , 0 ) ) h += y0 - y + 5 w += 10 bitmap = wx . EmptyBitmap ( w , h , - 1 ) memory . SelectObject ( bitmap ) memory . Blit ( 0 , 0 , w , h , context , x , y ) memory . Destroy ( ) context . Destroy ( ) print 'Saving bitmap ' , filename bitmap . SaveFile ( filename , wx . BITMAP_TYPE_PNG ) bitmap . Destroy ( )