[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] Better alternative to create QApplication without using a context manager
From:       BPL <spscener84 () gmail ! com>
Date:       2019-07-20 11:46:20
Message-ID: CAAfY3fYEoAdEL7PXzDkXnhKQs8Dm4o2zTSHSpPsmRTQAqdnD3w () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Phil,

A while ago I'd reported a bug related to the clipboard getting screwed up,
more
info about it here
https://www.riverbankcomputing.com/pipermail/qscintilla/2019-June/001404.html

At that time you'd provided a bug fix where you'd need to create a
QApplication
using a context manager, that bug fix worked wonderfully.

That said, wouldn't be possible to provide a better solution that doesn't
involve using a context manager at all? IMHO that'd be a much better
clean&ideal solution, that way all existing pyqt application would benefit
from the bug fix without having to change any existing production code,
plus... in pyside2 the bug doesn't exist when using the normal way of
creating the QApplication instance, check this one out:

USE_PYQT = True

if USE_PYQT:
    from PyQt5.Qt import *
else:
    from PySide2.QtGui import *
    from PySide2.QtCore import *
    from PySide2.QtWidgets import *

if __name__ == '__main__':
    app = QApplication([])
    w = QPlainTextEdit()
    w.setPlainText("hello world")
    w.show()
    app.exec_()

When using pyside2 the clipboard bug doesn't exist while in pyqt right
now you're forced to use the context manager, otherwise you'll get the
bug... but ideally both should expose the same right behaviour
without forcing the user to use any context manager :)

Thanks!

[Attachment #5 (text/html)]

<div dir="ltr">Phil,<div><br></div><div><div class="gmail-gs" \
style="margin:0px;padding:0px 0px 20px;width:1503px"><div class="gmail-" \
style=""><div id="gmail-:1i4" class="gmail-ii gmail-gt gmail-adO" \
style="direction:ltr;margin:8px 0px 0px;padding:0px"><div id="gmail-:1i3" \
class="gmail-a3s gmail-aXjCH" \
style="overflow:hidden;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:1.5"><div \
dir="ltr" style=""><div \
style="font-family:Arial,Helvetica,sans-serif;font-size:small">A while ago I&#39;d \
reported a bug related to the clipboard getting screwed up, more  </div><div \
style="font-family:Arial,Helvetica,sans-serif;font-size:small">info about it here  <a \
href="https://www.riverbankcomputing.com/pipermail/qscintilla/2019-June/001404.html">h \
ttps://www.riverbankcomputing.com/pipermail/qscintilla/2019-June/001404.html</a></div><div \
style="font-family:Arial,Helvetica,sans-serif;font-size:small"><br></div><div \
style="font-family:Arial,Helvetica,sans-serif;font-size:small">At that time you&#39;d \
provided a bug fix where you&#39;d need to create a QApplication</div><div \
style="font-family:Arial,Helvetica,sans-serif;font-size:small">using a context \
manager, that bug fix worked wonderfully.  </div><div \
style="font-family:Arial,Helvetica,sans-serif;font-size:small"><br></div><div \
style="font-family:Arial,Helvetica,sans-serif;font-size:small">That said, \
wouldn&#39;t be possible to provide a better solution that doesn&#39;t  </div><div \
style="font-family:Arial,Helvetica,sans-serif;font-size:small">involve using a \
context manager at all? IMHO that&#39;d be a much better  </div><div \
style="font-family:Arial,Helvetica,sans-serif;font-size:small">clean&amp;ideal \
solution, that way all existing pyqt application would benefit  </div><div \
style="font-family:Arial,Helvetica,sans-serif;font-size:small">from the bug fix \
without having to change any existing production code,  </div><div \
style="font-family:Arial,Helvetica,sans-serif;font-size:small">plus... in pyside2 the \
bug doesn&#39;t exist when using the normal way of  </div><div \
style="font-family:Arial,Helvetica,sans-serif;font-size:small">creating the \
QApplication instance, check this one out:</div><div \
style="font-family:Arial,Helvetica,sans-serif;font-size:small"><br></div><blockquote \
style="font-family:Arial,Helvetica,sans-serif;font-size:small;margin:0px 0px 0px \
40px;border:none;padding:0px"><div>USE_PYQT = True</div><div><br></div><div>if \
USE_PYQT:</div><div>      from PyQt5.Qt import *</div><div>else:</div><div>      from \
PySide2.QtGui import *</div><div>      from PySide2.QtCore import *</div><div>      \
from PySide2.QtWidgets import *</div><span class="gmail-im" \
style="color:rgb(80,0,80)"><div><br></div><div>if __name__ == \
&#39;__main__&#39;:</div><div>      app = QApplication([])</div></span><div>      w = \
QPlainTextEdit()</div><div>      w.setPlainText(&quot;hello world&quot;)</div><div>   \
w.show()</div><div>      app.exec_()</div><div><br></div></blockquote>When using \
pyside2 the clipboard bug doesn&#39;t exist while in pyqt right</div><div \
style="">now you&#39;re forced to use the context manager, otherwise you&#39;ll get \
the</div><div style="">bug... but ideally both should expose the same right behaviour \
</div><div style="">without forcing the user to use any context manager :)</div><div \
style=""><br></div><div style="">Thanks!</div><div style=""><img class="gmail-ajT" \
src="https://ssl.gstatic.com/ui/v1/icons/mail/images/cleardot.gif" style="background: \
url(&quot;https://www.gstatic.com/images/icons/material/system/1x/more_horiz_black_20dp.png&quot;) \
50% 50% / 20px no-repeat; height: 11px; opacity: 0.54; width: \
24px;"><br></div></div></div><div class="gmail-hi" \
style="font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:medium;bord \
er-bottom-left-radius:1px;border-bottom-right-radius:1px;padding:0px;width:auto;background:rgb(242,242,242);margin:0px"></div></div></div><br \
class="gmail-Apple-interchange-newline"></div></div>


[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic