Note that there are some explanatory texts on larger screens.

plurals
  1. PORunning a pyqt application twice from one prompt in spyder
    primarykey
    data
    text
    <p>I run a <code>pyqt4</code> application in <code>spyder</code>, I exit with <code>QtGui.QMainWindow.close()</code> and it returns me to the <code>spyder python interpreter</code> prompt. However, if I try and run the application again <code>runfile('C:/Python33/~/qtapp.py', wdir=r'C:/Python33/~/Appdir')</code> 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 <code>pyqt4</code> app again. This suggest to me that I am.</p> <ol> <li>Not shutting down the app correctly</li> <li>Not running the app correctly</li> </ol> <p>I want to be able to run the <code>pyqt4</code> app from the same prompt, this would speed up my dev time</p> <p>Here is the example code:</p> <pre><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_() </code></pre> <p>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:</p> <p>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.</p> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload