save the image in the clipboatd - in Python/Tkinter
Question: the subject says it all: is it possible to take an image present in the
clipboard and save it to file under Tkinter?


Answer: Here is a script that should get let you get arbitrary clipboard data on
windows.

    
    
    import win32clipboard as clip
    
    # The standard windows clipboard formats
    formats = ['CF_OEMTEXT', 'CF_PALETTE', 'CF_TEXT', 'CF_ENHMETAFILE', 'CF_UNICODETEXT', 
                'CF_BITMAP', 'CF_METAFILEPICT', 'CF_DIB', 'CF_DIBV5']
    
    def getFromClipboard(format):
        '""Returns a given type of data from the clipboard.'
        data = None
        clip.OpenClipboard(0)
        if clip.IsClipboardFormatAvailable(format):
            data = clip.GetClipboardData(format)
        clip.CloseClipboard()
        return data
    
    good_formats = []
    clip.OpenClipboard(0)
    for format in formats:
        if clip.IsClipboardFormatAvailable(format):
            good_formats.append(format)
    clip.CloseClipboard()
    
    # choose among the good formats here
    print good_formats
    
    # use the one you picked here
    data = getFromClipboard(good_formats[0])
    

Then `data` will be the raw image data and you can just save it to a file
normally.

<http://msdn.microsoft.com/en-us/library/ms649013%28v=VS.85%29.aspx>

<http://docs.activestate.com/activepython/2.4/pywin32/win32clipboard__GetClipboardData_meth.html>

Provide some information, more is out there.

