[PyQt] Conflict between setuptools & requirements in official PyQt5 docs

Elvis Stansvik elvstone at gmail.com
Mon Feb 8 17:17:42 GMT 2016


Den 8 feb 2016 6:03 em skrev "Damon Lynch" <damonlynch at gmail.com>:
>
> The PyQt5 docs explicitly say not to put the application startup logic in
a function e.g. main():
>
>
http://pyqt.sourceforge.net/Docs/PyQt5/pyqt4_differences.html#object-destruction-on-exit
>
> Whereas setuptools and its entry_points feature requires the startup
logic be in a function.
>
> From looking through a bunch of projects on github, I see that the great
majority simply ignore the official PyQt5 advice, and have a main() type
function with all their startup logic.
>
> However at least one project takes the approach of deleting PyQt objects
before exit (drawing on an insight offered by Dr. Koval):
>
> def main():
>     import sys
>     app = QtGui.QApplication(sys.argv)
>     window = DataViz()
>     window.show()
>     app.exec_()
>     # fixed segfaults at exit:
>     #
http://python.6.x6.nabble.com/Application-crash-on-exit-under-Linux-td5067510.html
>     del window
>     del app
>     sys.exit(0)
>
> if __name__ == '__main__':
>     main()
>
>
> Source:
https://github.com/subhacom/dataviz/blob/e62a591149750e5e5d21f13b4dfee28409a3d683/dataviz/dataviz.py
>
> Is this approach guaranteed to work as well as the approach specified in
the official docs?

I was not even aware of this advice from PyQt, but have been using a
function for several projects without problems. Guess I've just been lucky
:)

I'm also interested in answer.

Elvis
>
> Thanks
> Damon
>
>
>
>
> --
> http://www.damonlynch.net
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160208/6dc9aa57/attachment.html>


More information about the PyQt mailing list