0

I have set up a script that creates files to be run by one of my CNC machines. In order to load the file we scan them with a barcode reader. As it stands, after generating the file my program sends the file name to the clip board. I then paste the file into excel and change the font to 3of9 and the font size to 20.

Is there anyway i can get python to send the text to my clip board in the correct font and at the correct size?

This is the function i made to copy the text.

def copy2clip(txt):
    cmd = 'echo ' + txt.strip() + '|clip'
    return subprocess.check_call(cmd, shell=True)

Here is the actual copy operation as it stands now.

if item == 1:
    f.write('SIDE#5{\n$=left/face 6\n')
    copy2clip('*%11' + str(filename) + ' P*')
else:
    f.write('SIDE#5{\n$=right/face 4\n')
    copy2clip('*%11'+str(filename) + ' W*')
IHamilton
  • 35
  • 6
  • 1
    It looks like you're not actually relying on Python at all for this, but the `clip` utility, simply calling it through an exec. So, it feels like the question here should be "how do I add typesetting information when using `clip`" or something? (And I suspect the answer is "you don't, you want to use a better clipboard package, like `pywin32` with `ctypes`"). – Mike 'Pomax' Kamermans Dec 11 '18 at 01:11
  • (See https://stackoverflow.com/questions/579687/how-do-i-copy-a-string-to-the-clipboard-on-windows-using-python for some inspiration about alternative approaches that don't rely on "shell" calls) – Mike 'Pomax' Kamermans Dec 11 '18 at 01:15

0 Answers0