Pyside applications not closing properly

筅森魡賤 提交于 2019-12-05 18:26:55

I do not see this behavior. That means I can use sys.exit to stop a PySide program. However I more often use app.quit where app is the QApplication instance.

Example:

import sys
from PySide import QtGui

class MyWindow(QtGui.QWidget):
    def __init__(self):
        super().__init__()
        layout = QtGui.QVBoxLayout(self)
        button1 = QtGui.QPushButton('app.quit')
        button1.clicked.connect(app.quit)
        layout.addWidget(button1)
        button2 = QtGui.QPushButton('sys.exit')
        button2.clicked.connect(sys.exit)
        layout.addWidget(button2)

app = QtGui.QApplication([])

window = MyWindow()
window.show()

app.exec_()

Here both ways will work.

I'm on PySide 1.2.2 on Python 3.3 on Windows 7.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!