Image copied to clipboard doesn't persist on Linux

后端 未结 1 554
无人共我
无人共我 2021-01-25 14:35

I\'m trying to save an image to the system clipboard, so I wrote some code like this:

#!/usr/bin/python3

from PyQt5.Qt import QApplication
from PyQt5.QtWidgets          


        
相关标签:
1条回答
  • 2021-01-25 14:54

    Unfortunately for you, this is "normal" behaviour on Linux. By default, clipboard data is not persisted when an application closes. The usual work-around for this problem is to install a clipboard manager. For Ubuntu, see this wiki article for more details:

    • Ubuntu Wiki: Clipboard Persistence

    (NB: I have not actually tested any of the suggested solutions myself, so I don't know whether any of them will work with PyQt).

    The basic problem is that on Linux, the clipboard only stores a reference to the underlying data. This is very efficient in terms of storage, because the data is only copied when the client program actually requests it. But of course if the source application closes, the reference will be invalidated, and the clipboard will become empty.

    0 讨论(0)
提交回复
热议问题