Tk Source Code

View Ticket
Login
Ticket UUID: 1844034
Title: Clipboard doesn't persist after quit
Type: RFE Version: None
Submitter: catthish Created on: 2007-12-04 12:26:39
Subsystem: 52. [clipboard] Assigned To: fvogel
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2020-01-03 14:44:56
Resolution: Works For Me Closed By: fvogel
    Closed on: 2020-01-03 14:44:56
Description:
On OS X (and apparently Windows as well), the Tk clipboard is 'lazy' - it doesn't appear to be copied to the main system clipboard until asked.  If the Tk app is quit before this happens, the copied text is lost forever.

Obviously this has its uses (say, copying large chunks of video), but makes other workflows very frustrating.  I use gitk for browsing my git commits - typical workflow would be to fire up gitk from the terminal, find the commit I'm interested, copy the relevant SHA1 id, quit gitk, and paste that id to the terminal.  Tk's current pasteboard implementation prevents this.

Are there any workarounds?
User Comments: fvogel added on 2020-01-03 14:44:56:

On Windows this is really not the case, just try it:

package require Tk
pack [text .t]
.t insert end "abcdef"
.t tag add sel 1.2 1.4
event generate .t <<Copy>>
# quit wish and paste somewhere: "cd" is correctly inserted on Windows.

On Linux this depends on the presence of an adequate clipboard manager. We had a discussion about this on comp.lang.tcl very recently about this point and I think what Rich and Brian stated there is very clear. There is no bug in Tk here.

On macOS, I have just checked on Mojave: it's not (or no longer) the case either (same test script). Perhaps there is a clipboard manager on the machine I tried this but in any case I don't see a bug.