[Tutor] Help
eryksun
eryksun at gmail.com
Mon Jun 24 00:18:11 CEST 2013
On Thu, Jun 20, 2013 at 6:10 PM, Antonio Zagheni <zagheni at yahoo.com> wrote:
>
> I am a begginer in Python.
> I did a function that returns a string and I want to copy this to the clipboard.
> I have tried a lot of suggestions found at Google but nothing works properly.
> Is there an easy way to do that?
> I am using Python 2.7 and Windows 7.
It's simple to access the clipboard with Tkinter:
>>> from Tkinter import Tk, TclError
>>> root = Tk()
>>> root.withdraw()
''
>>> root.clipboard_clear()
>>> root.clipboard_append('eggs ')
>>> root.clipboard_append('and spam')
>>> root.clipboard_get()
'eggs and spam'
>>> root.clipboard_clear()
>>> try: root.clipboard_get()
... except TclError as e: print e
...
CLIPBOARD selection doesn't exist or form "STRING" not defined
More information about the Tutor
mailing list