<div dir="ltr">To really understand this I'd suggest you also reading these 2 related posts:<div><br></div><div><a href="https://www.riverbankcomputing.com/pipermail/qscintilla/2019-June/001404.html">https://www.riverbankcomputing.com/pipermail/qscintilla/2019-June/001404.html</a> </div><div><br></div><div>and</div><div><br></div><div><a href="https://www.riverbankcomputing.com/pipermail/pyqt/2019-July/041958.html">https://www.riverbankcomputing.com/pipermail/pyqt/2019-July/041958.html</a></div><div><br></div><div>That said, with the current latest pyqt you can guarantee the data copied into the clipboard will be preserved </div><div>by using a QApplication context manager, like this:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>from PyQt5.QtWidgets import QApplication</div><div><br></div><div>if __name__ == '__main__':</div><div> FORCE_BUG = True</div><div><br></div><div> if not FORCE_BUG:</div><div> with QApplication([]) as app:</div><div> clipboard = app.clipboard()</div><div> clipboard.setText("azerty")</div><div> print(QApplication.instance().clipboard().text())</div><div> print(app.clipboard().text())</div><div> print(clipboard.text())</div><div> else:</div><div> app = QApplication([])</div><div> clipboard = app.clipboard()</div><div> clipboard.setText("azerty")</div><div> print(QApplication.instance().clipboard().text())</div><div> print(app.clipboard().text())</div><div> print(clipboard.text())</div><div><br></div></blockquote>Ideally it wouldn't be necessary to use any context manager at all... but not sure how difficult would be for Phil<div>to provide that behaviour :/<br><div><br></div><div> </div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 23, 2019 at 6:29 PM Hugo Slepicka <<a href="mailto:hhslepicka@gmail.com">hhslepicka@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><p class="gmail-m_-8958623905114530601p1" style="margin:0px;font-stretch:normal;font-size:17px;line-height:normal;font-family:".SF UI Text";color:rgb(69,69,69)"><span class="gmail-m_-8958623905114530601s1" style="font-family:".SFUIText";font-size:17pt">This is what worked for me for all OSs:</span></p><p class="gmail-m_-8958623905114530601p2" style="margin:0px;font-stretch:normal;font-size:17px;line-height:normal;font-family:".SF UI Text";color:rgb(69,69,69);min-height:20.3px"><span class="gmail-m_-8958623905114530601s1" style="font-family:".SFUIText";font-size:17pt"></span><br></p><p class="gmail-m_-8958623905114530601p1" style="margin:0px;font-stretch:normal;font-size:17px;line-height:normal;font-family:".SF UI Text";color:rgb(69,69,69)"><span class="gmail-m_-8958623905114530601s1" style="font-family:".SFUIText";font-size:17pt">clipboard = QApplication.clipboard()</span></p><p class="gmail-m_-8958623905114530601p1" style="margin:0px;font-stretch:normal;font-size:17px;line-height:normal;font-family:".SF UI Text";color:rgb(69,69,69)"><span class="gmail-m_-8958623905114530601s1" style="font-family:".SFUIText";font-size:17pt">clipboard.setText(copy_text)</span></p><p class="gmail-m_-8958623905114530601p1" style="margin:0px;font-stretch:normal;font-size:17px;line-height:normal;font-family:".SF UI Text";color:rgb(69,69,69)"><span class="gmail-m_-8958623905114530601s1" style="font-family:".SFUIText";font-size:17pt">event = QEvent(QEvent.Clipboard)</span></p><p class="gmail-m_-8958623905114530601p1" style="margin:0px;font-stretch:normal;font-size:17px;line-height:normal;font-family:".SF UI Text";color:rgb(69,69,69)"><span class="gmail-m_-8958623905114530601s1" style="font-family:".SFUIText";font-size:17pt">QApplication.instance().sendEvent(clipboard, event)</span></p><p class="gmail-m_-8958623905114530601p1" style="margin:0px;font-stretch:normal;font-size:17px;line-height:normal;font-family:".SF UI Text";color:rgb(69,69,69)"><span class="gmail-m_-8958623905114530601s1" style="font-family:".SFUIText";font-size:17pt"><br></span></p></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 23, 2019 at 9:08 AM Tiger-222 <<a href="mailto:contact@tiger-222.fr" target="_blank">contact@tiger-222.fr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">FTR I have the same error on macOS.<br>
<br>
<br>
<br>
-----<br>
Mickaël Schoentgen. <br>
[FR] Personal blog: <a href="http://www.tiger-222.fr" rel="noreferrer" target="_blank">http://www.tiger-222.fr</a> <br>
--<br>
Sent from: <a href="http://python.6.x6.nabble.com/PyQt-f1792048.html" rel="noreferrer" target="_blank">http://python.6.x6.nabble.com/PyQt-f1792048.html</a><br>
_______________________________________________<br>
PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a><br>
<a href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt" rel="noreferrer" target="_blank">https://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br>
</blockquote></div></div>-- <br><div dir="ltr" class="gmail-m_-8958623905114530601gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="font-size:small"><div dir="ltr"><div dir="ltr"><div>Hugo Slepicka<br></div><div><font size="1"><b><a href="mailto:hhslepicka@gmail.com" target="_blank">hhslepicka@gmail.com</a></b></font></div><font size="1"><b>+1 631 855 5717</b></font></div></div></div></div></div></div></div></div></div>
_______________________________________________<br>
PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a><br>
<a href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt" rel="noreferrer" target="_blank">https://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br>
</blockquote></div>