[Tkinter-discuss] clipboard and bytes

Michael Lange klappnase at web.de
Wed Feb 28 18:12:13 EST 2018


On Wed, 28 Feb 2018 20:42:51 +0100
Michael Lange <klappnase at 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


More information about the Tkinter-discuss mailing list