Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我在 python 交互式 shell 中运行以下代码时
from PyQt4 import QtGui QtGui.QGraphicsScene()
蟒蛇崩溃。
为什么?
您需要先创建一个QApplication,然后才能使用任何 Qt GUI 元素。 通常它是这样完成的:
QApplication
from PyQt4 import QtGui import sys qapp = QtGui.QApplication(sys.argv) scene = QtGui.QGraphicsScene() ... qapp.exec_()