This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Tkinter in Python 3.4 on Windows don't post internal clipboard data to the Windows clipboard on exit
Type: behavior Stage: test needed
Components: Tkinter, Windows Versions: Python 3.4, Python 3.5
process
Status: open Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: Jon Snoo, Victor Korolkevich, paul.moore, serhiy.storchaka, steve.dower, terry.reedy, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2015-03-24 10:47 by Victor Korolkevich, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
issue23760.tcl serhiy.storchaka, 2015-06-12 13:40
Messages (5)
msg239107 - (view) Author: Victor Korolkevich (Victor Korolkevich) Date: 2015-03-24 10:47
From http://stackoverflow.com/questions/26321333/tkinter-in-python-3-4-on-windows-dont-post-internal-clipboard-data-to-the-windo

I use the following code to place result in clipboard.

from tkinter import Tk
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append("Result")

It works fine on Python version 3.3.5 and earlier. But in Python 3.4 it was receive empty clipboard. If I prevent the script from the immediate exit, adding input() after clipboard_append(), I see that clipboard contains the correct "Result".

If I run script, switch to any other window and press Ctrl+V, I receive "Result" and "Result" remains in clipboard after script exits.

I think in tcl/tk 8.6 clipboard_clear() affect system clipboard, but clipboard_append affect only internal tcl/tk clipboard that transfered to system clipboard only by OS request. Looks like it was done in Linux, that don't have system clipboard.
msg245206 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2015-06-12 04:49
I don't believe there's anything Python can do about this, unless it can be confirmed that this is a bug that's been fixed in a more recent version of Tcl/Tk 8.6, in which case we can update our dependency.  The easy test for whether updating Tcl/Tk in 3.4 (which uses 8.6.1) will do any good is to try this out with 3.5.0b2 (which uses the latest 8.6.4).
msg245251 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-06-12 13:40
Here is minimal reproducer on Tcl/Tk. I don't have a workaround.
msg254054 - (view) Author: Jon Snoo (Jon Snoo) Date: 2015-11-04 14:12
I tested the code posted by Victor with Python 3.5 (which uses Tcl/Tk 8.6.4) and I still get an empty clipboard when the script exits.

I also downloaded ActiveState's Tcl binary which is also version 8.6.4, and tested the minimal reproducer posted by Serhiy with this

    wish issue23760.tcl

and it works i.e. I get "Result" in the system clipboard.

I don't really know what to make of this.
msg254055 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-11-04 15:10
Related Tk issues:

http://core.tcl.tk/tk/tktview/822002ffffffffffffff
http://core.tcl.tk/tk/tktview/732662ffffffffffffff
http://core.tcl.tk/tk/tktview/1844034fffffffffffff
http://core.tcl.tk/tk/tktview/939389ffffffffffffff

The problem should be fixed (at least on Windows) in the last issue, but perhaps Tkinter doesn't execute this code.

A workaround is to make a pause about 0.1 sec (can be depend on perfomance of your computer, it doesn't work if the pause is too short). Append following lines to you example:

r.after(100, r.destroy)
r.mainloop()
History
Date User Action Args
2022-04-11 14:58:14adminsetgithub: 67948
2015-11-04 15:10:42serhiy.storchakasetmessages: + msg254055
2015-11-04 14:12:56Jon Snoosetnosy: + Jon Snoo
messages: + msg254054
2015-06-12 13:40:59serhiy.storchakasetfiles: + issue23760.tcl
status: pending -> open
messages: + msg245251
2015-06-12 04:49:58zach.waresetstatus: open -> pending
resolution: third party
messages: + msg245206
2015-06-12 04:40:08martin.pantersetnosy: + paul.moore, tim.golden, zach.ware, steve.dower, - martin.panter
components: + Windows
2015-03-27 21:25:32terry.reedysetnosy: + terry.reedy, serhiy.storchaka

stage: test needed
2015-03-24 14:01:48martin.pantersetnosy: + martin.panter
2015-03-24 10:53:35Victor Korolkevichsetversions: + Python 3.5
2015-03-24 10:47:56Victor Korolkevichcreate