Many thanks! I works within the same process. When I try to launch it twice, so I can have clipboard exchange between different processes
I get the following exception: Traceback (most recent call last): File "/usr/lib/python3.6/tkinter/__init__.py", line 1702, in __call__ return self.func(*args) File "foo.py", line 41, in paste res = root.tk.call(clip) _tkinter.TclError: invalid command name "139879786444744cp" I saw in the documentation that by default it uses the UTF8STRING as type I've tried to force it to type="STRING" but with no success ________________________________________ From: Tkinter-discuss [tkinter-discuss-bounces+vasilis.vlachoudis=cern...@python.org] on behalf of Michael Lange [klappn...@web.de] Sent: Thursday, March 01, 2018 00:12 To: tkinter-discuss@python.org Subject: Re: [Tkinter-discuss] clipboard and bytes On Wed, 28 Feb 2018 20:42:51 +0100 Michael Lange <klappn...@web.de> wrote: (...) > So at least this primitive seems to work. Maybe you can use this > technique to achieve what you want. Or maybe this slightly modified example comes closer to what you are looking for: from tkinter import * root = Tk() def copy(string): def cp(): return string copyfunc = (root.register(cp)) return(copyfunc) root.clipboard_clear() root.clipboard_append(copy(b'foobar'), type='foo') def paste(ev): clip = root.clipboard_get(type='foo') res = root.tk.call(clip) print('->', res, type(res)) root.bind('<F1>', paste) root.mainloop() Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. "... freedom ... is a worship word..." "It is our worship word too." -- Cloud William and Kirk, "The Omega Glory", stardate unknown _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss