Getting the XP clipboard in tkinter

Brian Kelley bkelley at wi.mit.edu
Mon Jul 1 09:03:27 EDT 2002


Just in case you are using windows:

     # if we are running on windows, attach to the
     # windows clipboard
     import win32clipboard as clip

     def getFromClipboard():
         'Returns a list of the lines of text in the clipboard.'
         clip.OpenClipboard(0)
         if clip.IsClipboardFormatAvailable(clip.CF_TEXT):
            newText = clip.GetClipboardData(clip.CF_TEXT)
            lines = newText.split('\r\n')
         clip.CloseClipboard()
         return lines

Brian Kelley
Whitehead Institute for Biomedical Research




More information about the Python-list mailing list