[QGIS-Developer] Odd error

Paul Wittle paul.wittle at dorsetcouncil.gov.uk
Thu Apr 22 01:57:13 PDT 2021


Hi,

I’ve been thinking about this a bit more and I think the issue may relate specifically to the following lines:
dialog = processing.createAlgorithmDialog("script:atobroute",{})
       dialog.show()

I think the issue is that the dialog.show() opens the script dialog but that dialog then has interactive options where you can select a point from the map canvas. It is when you try to select the coordinates that QGIS crashes.

I think I tried using .exec_ instead of .show but of course the dialog opens and closes straight away. I think the issue may be that my plugin is waiting for the user to dismiss the dialog but is unhappy when it is hidden by the select from canvas tool.

I’ve slept since I wrote the script but I think the select from map is default functionality and the fields are defined as
self.addParameter(QgsProcessingParameterPoint(self.ORIG, 'Origin coordinates',None,True))

Is there a better way to open a script from a button on the toolbar. Ideally I want to simply replicate the behaviour of just double clicking the script from the processing toolbox.

Thanks,
Paul


From: Paul Wittle
Sent: 21 April 2021 09:16
To: nagyrobi_r at yahoo.com
Subject: RE: [QGIS-Developer] Odd error

Hi,

Yes I used plugin builder as a base for the plugin. Here is the code in question:

#Create the routing toolbar
        self.routebar = self.iface.addToolBar("Routing Tools")
        self.routebar.setObjectName(u'Routing Tools')

        text = QLabel(
            QCoreApplication.translate('CouncilPlugin', 'Routing Tools:')
            )
        #No action to connect to this!
        self.routebar.addWidget(text)

        route1 = QAction(
            QIcon(':/plugins/council_plugin/AtoB.png'),
            QCoreApplication.translate('CouncilPlugin', 'Route from A to B'),
            self.iface.mainWindow()
            )
        route1.triggered.connect(self.AtoB)
        self.routebar.addAction(route1)

#Routing Tools
    def AtoB(self):
        self.CheckRoutingTools() #Always check the scripts are up to date first
        dialog = processing.createAlgorithmDialog("script:atobroute",{})
        dialog.show()

I don’t think it gives an error message. QGIS just disappears and you have to re-open it.

Thanks,
Paul


From: nagyrobi_r at yahoo.com<mailto:nagyrobi_r at yahoo.com> <nagyrobi_r at yahoo.com<mailto:nagyrobi_r at yahoo.com>>
Sent: 21 April 2021 09:11
To: Paul Wittle <paul.wittle at dorsetcouncil.gov.uk<mailto:paul.wittle at dorsetcouncil.gov.uk>>
Subject: Re: [QGIS-Developer] Odd error

Hei!

Have you bilt the plugin using "plugin builder?
Could you send the error message?

Cheers,
Robert

On Wed, Apr 21, 2021 at 10:00 AM, Paul Wittle
<paul.wittle at dorsetcouncil.gov.uk<mailto:paul.wittle at dorsetcouncil.gov.uk>> wrote:

Hi,



I have a python script that I wrote which routes from point A to B using the default tools in QGIS. If I go to the processing toolbox and open the dialog it runs fine and everything is great.



I also have a python plugin and I put a button in a toolbar to open the same script. It loads the dialog but when you try to run it the whole thing crashes out and QGIS disables my plugin.



Does anyone have any suggestions as to what I might have done wrong?



I’m assuming the issue is related to how I’m calling the script from my plugin rather than the script itself as it runs independently from the processing toolbox fine 😊



Any suggestions would be appreciated.



Paul Wittle

[cid:image001.jpg at 01D7375D.DD71ADE0]<https://www.dorsetcouncil.gov.uk/>

Business Solutions Analyst (GIS)

ICT Operations

Dorset Council

01305 228473

dorsetcouncil.gov.uk<https://www.dorsetcouncil.gov.uk>



[cid:image003.png at 01D7375D.DD71ADE0]<https://www.facebook.com/DorsetCouncilUK>

[cid:image005.png at 01D7375D.DD71ADE0]<https://instagram.com/DorsetCouncilUK>

[cid:image007.png at 01D7375D.DD71ADE0]<https://twitter.com/DorsetCouncilUK>


This e-mail and any files transmitted with it are intended solely for the use of the individual or entity to whom they are addressed. It may contain unclassified but sensitive or protectively marked material and should be handled accordingly. Unless you are the named addressee (or authorised to receive it for the addressee) you may not copy or use it, or disclose it to anyone else. If you have received this transmission in error please notify the sender immediately. All traffic may be subject to recording and/or monitoring in accordance with relevant legislation. Any views expressed in this message are those of the individual sender, except where the sender specifies and with authority, states them to be the views of Dorset Council. Dorset Council does not accept service of documents by fax or other electronic means. Virus checking: Whilst all reasonable steps have been taken to ensure that this electronic communication and its attachments whether encoded, encrypted or otherwise supplied are free from computer viruses, Dorset Council accepts no liability in respect of any loss, cost, damage or expense suffered as a result of accessing this message or any of its attachments. For information on how Dorset Council processes your information, please see www.dorsetcouncil.gov.uk/data-protection<http://www.dorsetcouncil.gov.uk/data-protection>
_______________________________________________
QGIS-Developer mailing list
QGIS-Developer at lists.osgeo.org<mailto:QGIS-Developer at lists.osgeo.org>
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
This e-mail and any files transmitted with it are intended solely for the use of the individual or entity to whom they are addressed. It may contain unclassified but sensitive or protectively marked material and should be handled accordingly. Unless you are the named addressee (or authorised to receive it for the addressee) you may not copy or use it, or disclose it to anyone else. If you have received this transmission in error please notify the sender immediately. All traffic may be subject to recording and/or monitoring in accordance with relevant legislation. Any views expressed in this message are those of the individual sender, except where the sender specifies and with authority, states them to be the views of Dorset Council. Dorset Council does not accept service of documents by fax or other electronic means. Virus checking: Whilst all reasonable steps have been taken to ensure that this electronic communication and its attachments whether encoded, encrypted or otherwise supplied are free from computer viruses, Dorset Council accepts no liability in respect of any loss, cost, damage or expense suffered as a result of accessing this message or any of its attachments. For information on how Dorset Council processes your information, please see www.dorsetcouncil.gov.uk/data-protection
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210422/840de13d/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 5708 bytes
Desc: image001.jpg
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210422/840de13d/attachment-0001.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 4194 bytes
Desc: image003.png
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210422/840de13d/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image005.png
Type: image/png
Size: 6142 bytes
Desc: image005.png
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210422/840de13d/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image007.png
Type: image/png
Size: 2536 bytes
Desc: image007.png
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210422/840de13d/attachment-0005.png>


More information about the QGIS-Developer mailing list