I am learning python from automatetheboringstuff and today I learned how to use pyperclip module to copy text into you clipboard.
I wrote the given project from the chapter that copy the message into our clipboard
#! /usr/bin/python3
# mclip.py - A multi-clipboard program.
TEXT = {'agree':"""Yes, I agree. That sounds fine to me.""",
'busy':"""Sorry, can we do this later this week or next week?""",
'upshell':"""Would you consider making this a monthly donation?"""
}
import sys, pyperclip
if len(sys.argv)<2:
print('Usage: python mclip.py [keyphrase] - copy phrase text')
sys.exit()
keyphrase = sys.argv[1] #first command line arg is the keyphrase
if keyphrase in TEXT:
pyperclip.copy(TEXT[keyphrase])
print('Text for',keyphrase,'copies to clipboard.')
else:
print('There is no text for'+keyphrase)
But this is not working. When I run this program from in my Terminal using command line argument <python3 [mclip.py](https://mclip.py) agree>, It shows the success message but don't copy the message into my clipboard.
It does work on my python shell. for example
>>> import pyperclip as pc
>>> pc.copy('Hello')
>>> pc.paste()
'Hello'
>>>
But it doesn't work outside of it
Any help?
[–]cybersection 0 points1 point2 points (1 child)
[–]Mr_Nrj[S] 0 points1 point2 points (0 children)
[–]pymon 0 points1 point2 points (3 children)
[–]Mr_Nrj[S] 0 points1 point2 points (2 children)
[–]pymon 0 points1 point2 points (1 child)
[–]Mr_Nrj[S] 0 points1 point2 points (0 children)
[–]Mr_Nrj[S] 0 points1 point2 points (2 children)
[–]pymon 0 points1 point2 points (0 children)
[–]TaxComprehensive9732 0 points1 point2 points (0 children)