我在spyder
運行了一個pyqt4
應用程序,我用QtGui.QMainWindow.close()
退出,它返回到spyder python interpreter
提示符。但是,如果我嘗試再次運行應用程序runfile('C:/Python33/~/qtapp.py', wdir=r'C:/Python33/~/Appdir')
窗口不顯示。我必須關閉python解釋器窗口並打開一個新窗口,然後才能再次運行我的pyqt4
應用程序。這表明我是。從Spyder中的一個提示符運行一次pyqt應用程序兩次
- 不關閉應用程序正確
- 沒有運行的應用程序正確
我希望能夠從同一提示符下運行pyqt4
應用程序,這將加速我的開發時間
下面是示例代碼:
from PyQt4 import QtCore, QtGui, Qwt5
import sys
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(200, 200)
self.checkBox = QtGui.QCheckBox(MainWindow)
self.checkBox.setGeometry(QtCore.QRect(100, 100, 70, 17))
self.checkBox.setObjectName("checkBox")
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "Dialog",None, QtGui.QApplication.UnicodeUTF8))
self.checkBox.setText(QtGui.QApplication.translate("MainWindow", "CheckBox", None, QtGui.QApplication.UnicodeUTF8))
class MainWindow(QtGui.QMainWindow,Ui_MainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.setupUi(self)
app = QtGui.QApplication(sys.argv)
form = MainWindow()
form.show()
app.exec_()
我跑後它一旦窗口出現,我再次運行它後窗口不顯示, 這是我的版本信息:
Python 3.3.2(v3.3.2:d047928ae3f6,2013年5月16日,00:03:43 )win32上的[MSC v.1600 32位(Intel)] 輸入「help」,「copyright」,「credits」或「license」以獲取更多信息。
導入的NumPy 1.7.1,SciPy 0.12.0,Matplotlib 1.3.0 + guidata 1.6.1,guiqwt 2.3.1 鍵入「科學」的更多細節。
(* Spyder dev here *)你可以發佈一個我可以在我身邊測試的最小例子嗎? –
再次看到上面的帖子... – laptop2d
[關閉PyQt4 Gui應用程序後Python內核崩潰]的可能重複(http://stackoverflow.com/questions/24041259/python-kernel-crashes-after-closing-an-pyqt4- GUI的應用程序) – patrickvacek