在OSX 10.13.4
上使用python3-spyder使用python3-spyder我有一个正常工作的QT设计器应用程序。当我运行时,我会在Python控制台
中获得此错误文件" .../sitecustomize.py",第102行,在Execfile中 exec(compile(f.read((,文件名,'exec'(,名称空间(
file" .../ercory/hello_world/hello_code.py",第34行,in sys.exit(app.exec _(((
SystemExit:-1
这是一个问题吗?
主代码在下方,hello_world是QT设计师UI>> PY文件
import sys
from PyQt5 import QtCore
from PyQt5.QtWidgets import QMainWindow, QApplication
from hello_world import Ui_MainWindow
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
# Set up the user interface from Designer.
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
#
# add text to QTextBrowser
#
self.ui.textBrowser.setText("Hello World n")
self.ui.textBrowser.append("t Hello World Again")
self.ui.textBrowser.setAlignment(QtCore.Qt.AlignRight)
self.show()
app = QApplication(sys.argv)
window = MainWindow()
sys.exit(app.exec_())
在pyqt5中,您不需要再调用 sys.exit()
了。只是使用:
app.exec()
你很好。
请参阅我的pyqt应用程序中应该使用`app.exec((`or app.exec _((`?有关更多信息。