Posted By

laurenceosx on 07/19/09


Tagged

jython


Versions (?)

Jython getClipboardText


 / Published in: Python
 

  1. def getClipboardText():
  2. # jython get clipboard text
  3. from java.awt.datatransfer import DataFlavor
  4. from java.awt import Toolkit
  5.  
  6. clipboard = Toolkit.getDefaultToolkit().getSystemClipboard()
  7. contents = clipboard.getContents(None)
  8. gotText = (contents != None) and contents.isDataFlavorSupported(DataFlavor.stringFlavor)
  9. return contents.getTransferData(DataFlavor.stringFlavor)
  10.  
  11. getCbText = getClipboardText

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: laurenceosx on July 19, 2009

For some reason in the Guess Visualization app, I always had to do a fresh import every time for the get clipboard to work.

You need to login to post a comment.