[Qgis-user] QGIS3 quits after PyQt Script 2 run

1520 gis juliermeopensourcedeveloper at gmail.com
Wed Aug 16 10:15:07 PDT 2023


Hi all,

I wrote the PyQt script below and I am running it through QGIS3. When I run
it for the first time after opening it in QGIS3, the application's window
pops up smoothly. However, when I close the window and run the script,
QGIS3 readily quits.  That may be something related to the event loop, but
I'm unsure and don't know how to stop the QGIS3 shutdown for the subsequent
runs.  Any hint on how to fix this issue will be very appreciated.

import sys
from PyQt5.QtCore import (QSize,
                          Qt)
from PyQt5.QtWidgets import (QApplication,
                              QWidget,
                              QPushButton,
                              QMainWindow)
class MainWindow(QMainWindow):
    def _init_(self):
        super()._init_()
        self.setWindowTitle("My App")
        button = QPushButton("Press Me!")


        self.setCentralWidget(button)
        self.setFixedSize(QSize(400,300))
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()
-- 
##########################################
*Julierme G Pinheiro*
*SDI Expert & Geoprocessing Specialist*
Phone: +55 61 99994-3569
Website: GIS
<https://www.udemy.com/course/qgis-server-para-iniciantes-instalacao-e-configuracao/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20230816/a7f3106c/attachment.htm>


More information about the QGIS-User mailing list