I'm trying to test a program written in Python with a front panel generated with Qt Designer (converted from .ui to .py using pyuic4). I can make the following code work outside Emacs, from a terminal (it is just a main window with some labels and buttons):
from PyQt4 import QtCore, QtGui
from panelSimple import Ui_VentanaPrincipal
class Window(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.ui = Ui_VentanaPrincipal()
self.ui.setupUi(self)
if __name__ == '__main__':
import sys
app = QtGui.QApplication(sys.argv)
miVentana = Window()
miVentana.show()
sys.exit(app.exec_())
I would like to execute this code from within Emacs, but when I send the buffer to the Python interpreter, and it opens an "Inferior Python" buffer, nothing happens.
On the other hand, if I don't use any graphical user interface, python programs work very well.
Is it possible to make my program's GUI execute from inside Emacs?
I started using Spacemacs with its default settings. For my tries I select a virtual environment (with PyQt4 installed), and then I send the buffer to the interpreter. I don't know what other information could be useful to answer my question.
M-x shell
and entering the same command?print(__name__)
before the if, it writes__main__
. But then, nothing inside the if executes. Do you know why?With prefix ARG allow execution of code inside blocks delimited by "if __name__== '__main__':"
. So SPC u m s b in Spacemacs or C-u C-c C-c works. Thank you!