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

2023-08-17 Thread 1520 gis via QGIS-User
Dear Ludwig,

That was it. I don't know somehow the init function went through with just
one underscore. Now it's working smoothly and beautifully. QGIS is just
amazing.

Thank you very much for your contribution and help.

Best regards

Julierme

On Thu, Aug 17, 2023 at 4:37 AM Ludwig Kniprath 
wrote:

> Hi Julierme,
>
> that's another and not a new problem, the button-widget and setFixedSize
> did not work before and even do not work in standalone-python outside QGis.
>
> The reason is quite simple, we overlooked it before: double-underscores
> for the __init__-functions.
>
>
> Here the running code, which does what You want (commented lines for
> QGis-usage, uncomment for standalone):
>
>
> 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()
>
>
>
>
> hth
>
> Ludwig
>
>
>
> Am 17.08.23 um 04:14 schrieb 1520 gis:
>
> Hi Ludwig,
>
> Thank you very much for your reply. You're right, QGIS stopped crashing,
> but now the button widget is not being carried out by the application
> window and neither the methods are working properly like the
> self.setFixedSize(QSize(400,300)). I am sending a window screenshot in
> attachment.
>
> I appreciated your time and help.
>
> Kind regards
>
> Julierme
>
> On Wed, Aug 16, 2023 at 4:07 PM Ludwig Kniprath via QGIS-User <
> qgis-user@lists.osgeo.org> wrote:
>
>> Hi Julierme,
>>
>> I think Your problem is, that You try to create a new application with
>> "app = QApplication(sys.argv)" inside a running QGis, which already is a
>> running Qt-application.
>>
>> Simplified code should perform without crash:
>>
>> 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))
>>
>> window = MainWindow()
>> window.show()
>>
>>
>> hth
>>
>> Ludwig
>> Am 16.08.23 um 19:15 schrieb 1520 gis via QGIS-User:
>>
>> 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 4-3569
>> Website: GIS
>> 
>>
>> ___
>> QGIS-User mailing listqgis-u...@lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>
>> ___
>> QGIS-User mailing list
>> QGIS-User@lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>
>
>
> --
> ##
> *Julierme G Pinheiro*
> *SDI Expert & Geoprocessing Specialist*
> Phone: +55 61 4-3569
> Website: GIS
> 
>
>

-- 
##
*Julierme G Pinheiro*
*SDI Expert & Geoprocessing Specialist*
Phone: +55 61 4-3569
Website: GIS

___
QGIS-User mai

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

2023-08-17 Thread Ludwig Kniprath via QGIS-User

Hi Julierme,

that's another and not a new problem, the button-widget and setFixedSize 
did not work before and even do not work in standalone-python outside QGis.


The reason is quite simple, we overlooked it before: double-underscores 
for the __init__-functions.



Here the running code, which does what You want (commented lines for 
QGis-usage, uncomment for standalone):



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()




hth

Ludwig




Am 17.08.23 um 04:14 schrieb 1520 gis:

Hi Ludwig,

Thank you very much for your reply. You're right, QGIS stopped 
crashing, but now the button widget is not being carried out by the 
application window and neither the methods are working properly like 
the self.setFixedSize(QSize(400,300)). I am sending a window 
screenshot in attachment.


I appreciated your time and help.

Kind regards

Julierme

On Wed, Aug 16, 2023 at 4:07 PM Ludwig Kniprath via QGIS-User 
 wrote:


Hi Julierme,

I think Your problem is, that You try to create a new application
with "app = QApplication(sys.argv)" inside a running QGis, which
already is a running Qt-application.

Simplified code should perform without crash:

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))

window = MainWindow()
window.show()


hth

Ludwig

Am 16.08.23 um 19:15 schrieb 1520 gis via QGIS-User:

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 4-3569
Website: GIS



___
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info:https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-user

___
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user



--
##
*Julierme G Pinheiro*
*SDI Expert & Geoprocessing Specialist*
Phone: +55 61 4-3569
Website: GIS 
___
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


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

2023-08-16 Thread 1520 gis via QGIS-User
Hi Ludwig,

Thank you very much for your reply. You're right, QGIS stopped crashing,
but now the button widget is not being carried out by the application
window and neither the methods are working properly like the
self.setFixedSize(QSize(400,300)). I am sending a window screenshot in
attachment.

I appreciated your time and help.

Kind regards

Julierme

On Wed, Aug 16, 2023 at 4:07 PM Ludwig Kniprath via QGIS-User <
qgis-user@lists.osgeo.org> wrote:

> Hi Julierme,
>
> I think Your problem is, that You try to create a new application with
> "app = QApplication(sys.argv)" inside a running QGis, which already is a
> running Qt-application.
>
> Simplified code should perform without crash:
>
> 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))
>
> window = MainWindow()
> window.show()
>
>
> hth
>
> Ludwig
> Am 16.08.23 um 19:15 schrieb 1520 gis via QGIS-User:
>
> 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 4-3569
> Website: GIS
> 
>
> ___
> QGIS-User mailing listqgis-u...@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>
> ___
> QGIS-User mailing list
> QGIS-User@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>


-- 
##
*Julierme G Pinheiro*
*SDI Expert & Geoprocessing Specialist*
Phone: +55 61 4-3569
Website: GIS

___
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


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

2023-08-16 Thread Ludwig Kniprath via QGIS-User

Hi Julierme,

I think Your problem is, that You try to create a new application with 
"app = QApplication(sys.argv)" inside a running QGis, which already is a 
running Qt-application.


Simplified code should perform without crash:

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))

window = MainWindow()
window.show()


hth

Ludwig

Am 16.08.23 um 19:15 schrieb 1520 gis via QGIS-User:

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 4-3569
Website: GIS 



___
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info:https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-user___
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


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

2023-08-16 Thread 1520 gis via QGIS-User
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 4-3569
Website: GIS

___
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user