I run a pyqt4
application in spyder
, I exit with QtGui.QMainWindow.close()
and it returns me to the spyder python interpreter
prompt. However, if I try and run the application again runfile('C:/Python33/~/qtapp.py', wdir=r'C:/Python33/~/Appdir')
The window doesn't show. I have to shut the python interpreter window down and open a new one up before I can run my pyqt4
app again. This suggest to me that I am.
- Not shutting down the app correctly
- Not running the app correctly
I want to be able to run the pyqt4
app from the same prompt, this would speed up my dev time
Here is the example code:
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_()
After I run it once the window shows up, after I run it again the window doesn't show up, Here's my version info:
Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.
Imported NumPy 1.7.1, SciPy 0.12.0, Matplotlib 1.3.0 + guidata 1.6.1, guiqwt 2.3.1 Type "scientific" for more details.