"copy text to clipboard" component?

Hi…,

I would like to have a “copy text to clipboard” component. I’ve tried a Python script, but I failed.

Any ideas?

Thanks

Michael
www.flexiCAD.com

Copy text? Rich text? Images? Byte arrays?

sorry to be imprecise. text is my desire. :wink:

try this:

import os 
data = "hello world"
os.system("echo '%s' | pbcopy" % data)

taken from here

Actually that didn’t work :slight_smile:

This works:

import subprocess

def copy2clip(txt):
    cmd='echo '+txt.strip()+'|clip'
    return subprocess.check_call(cmd, shell=True)
    
copy2clip('This is on my clipboard!')
2 Likes