Copying in Python Mode?

edited April 2016 in Python Mode

How can you copy to the clipboard in Python Mode? I’m working on something that will generate a long string of text for the user to input somewhere else, and it would be greatly helpful if this text could be copied rather than written out by hand.

Thank you!

*edit: I thought I might try to import a Python library, Pyperclip, but nothing I try (putting the Pyperclip folder within the sketch folder, or the libraries folder, etc.) works. Where should I put it (or will this not work no matter where I put it)?

*edit 2: I found something that works, but I think it only works for Macs (from this site):

import subprocess

def clipboard_paste():
    p = subprocess.Popen(['pbpaste'], stdout=subprocess.PIPE)
    retcode = p.wait()
    data =
    return data

def clipboard_copy(data):
    p = subprocess.Popen(['pbcopy'], stdin=subprocess.PIPE)
    retcode = p.wait()
Sign In or Register to comment.