R
R
RussianSuburban2016-02-29 17:39:11
Python
RussianSuburban, 2016-02-29 17:39:11

What are the fundamental features of running a python script from IDLE under windows?

Pyrhon 3.4, PyQt4, Windows 8.1
I have a project with two forms:
First:

class MyForm(QtGui.QMainWindow,Ui_Topiq):
    logShow = pyqtSignal()
    def __init__(self, parent=None):
        super(MyForm,self).__init__(parent)
        self.setupUi(self)
        #Делаем стартовое окошко установленным на первый слой виждетов
        self.stackedWidget.setCurrentIndex(0);
   ....

Second:
class LogWindow(QtGui.QWidget,Ui_Log):
    def __init__(self,parent=None):
        super(LogWindow,self).__init__(parent)
        self.setupUi(self)
    ...

Main program:
if __name__ == "__main__":
    ...
    app = QtGui.QApplication(sys.argv)
    mainWindow = MyForm()
    log_ = LogWindow()
    #добавляем обработчик клика по статус-бару
    mainWindow.logShow.connect(log_.show)
    mainWindow.show()
    sys.exit(app.exec_())

Everything works as it should if run directly from the IDLE editor.
If after that you save the file and try to run it by double-clicking or from the console, the form will appear for a moment and immediately disappear, and the script will end without giving any errors.
If the file is run from some other ide (I tried PyCharm and Eclipse), the behavior will be exactly the same as when double-clicking or running from the console, which does not suit me.
If you comment out the connect line, the script will run normally in all cases.
#добавляем обработчик клика по статус-бару
#mainWindow.logShow.connect(log_.show)

What is the fundamental difference between running a script from IDLE and any other way? What is the reason for this behaviour? I don't even know how to make a Google request. Help me please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TomasHuk, 2016-03-01
@RussianSuburban

Try renaming the file from *.py to *.pyw and double clicking it.
Here was a similar question .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question