Re: [Qgis-user] PyQGIS: wipe all xyz connections

2020-09-23 Thread 1520 gis
Hi Erich Purpur,

I am a Python coding beginner and made some changes according to your
reply. I have a XYZ connection for OpenStreetMap. But after hitting the
button wipeAllConnectionsXyz in a QGIS Plugin, I did not get any error
message, but the OSM connection was not removed. Find the code below:

def removeAllConnectionsXYZ(self):
s = QSettings()
xyz = 'qgis/connections-xyz'
groupsXYZ = s.childGroups()
for group in groupsXYZ:
s.beginGroup(xyz)
s.remove("")
s.endGroup()

self.dlg.wipeAllConnectionsXyz.clicked.connect(
self.removeAllConnectionsXYZ)

# Kind regards

# Julierme


On Wed, Sep 23, 2020 at 1:54 PM Erich Purpur  wrote:

> Is this regarding the following stackoverflow thread?
> https://gis.stackexchange.com/questions/374808/pyqt5-wipe-xyz-connections
>
> If so, your error message as you posted it in StackOverflow is:
> for group in getGroupXYZ(self): NameError: name 'getGroupXYZ' is not
> defined
>
> From what I gather in the code posted in SO, you are trying to iterate
> over getGroupXYZ(), which is a function. This is not an object which holds
> multiple items, which is the purpose of a loop. However, in your
> getGroupXYZ() function, you return an object called groupsXYZ. You should
> loop of the groupsXYZ object, not the function.
>
> -Erich
>
>
>
>
> On Wed, Sep 23, 2020 at 11:38 AM 1520 gis <
> juliermeopensourcedevelo...@gmail.com> wrote:
>
>> Dear all,
>>
>> I am writing a PyQT5 QGIS Plugin to wipe out all xyz connections
>> available in QGS projects.
>>
>> I wrote the code below, but I am not achieving my goal and I did not
>> understand the structure of xyz connections.
>>
>> def removeAllConnectionsXYZ(self):
>> s = QSettings()
>> xyz = 'qgis/connections-xyz'
>> groupsXYZ = s.childGroups()
>>
>> for group in groupsXYZ:
>> s.beginGroup(xyz)
>> s.remove("")
>> s.endGroup()
>> self.dlg.wipeAllConnectionsXyz.clicked.connect(
>> self.removeAllConnectionsXYZ)
>>
>>
>>
>>
>> # Any comment will be very appreciated.
>>
>> #Thank you for your time in advance
>>
>> #Julierme
>> ___
>> 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

Re: [Qgis-user] PyQGIS: wipe all xyz connections

2020-09-23 Thread Erich Purpur
Is this regarding the following stackoverflow thread?
https://gis.stackexchange.com/questions/374808/pyqt5-wipe-xyz-connections

If so, your error message as you posted it in StackOverflow is:
for group in getGroupXYZ(self): NameError: name 'getGroupXYZ' is not defined

>From what I gather in the code posted in SO, you are trying to iterate over
getGroupXYZ(), which is a function. This is not an object which holds
multiple items, which is the purpose of a loop. However, in your
getGroupXYZ() function, you return an object called groupsXYZ. You should
loop of the groupsXYZ object, not the function.

-Erich




On Wed, Sep 23, 2020 at 11:38 AM 1520 gis <
juliermeopensourcedevelo...@gmail.com> wrote:

> Dear all,
>
> I am writing a PyQT5 QGIS Plugin to wipe out all xyz connections available
> in QGS projects.
>
> I wrote the code below, but I am not achieving my goal and I did not
> understand the structure of xyz connections.
>
> def removeAllConnectionsXYZ(self):
> s = QSettings()
> xyz = 'qgis/connections-xyz'
> groupsXYZ = s.childGroups()
>
> for group in groupsXYZ:
> s.beginGroup(xyz)
> s.remove("")
> s.endGroup()
> self.dlg.wipeAllConnectionsXyz.clicked.connect(
> self.removeAllConnectionsXYZ)
>
>
>
>
> # Any comment will be very appreciated.
>
> #Thank you for your time in advance
>
> #Julierme
> ___
> 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

Re: [Qgis-user] PyQGIS: wipe all xyz connections

2020-09-23 Thread Etienne Trimaille
You need to clarify if you want to remove all layers based on XYZ which are
loaded in the current project
Or if you want to remove all XYZ connections which are in the Browser Panel?

It's two different things.

Le mer. 23 sept. 2020 à 17:39, 1520 gis <
juliermeopensourcedevelo...@gmail.com> a écrit :

> Dear all,
>
> I am writing a PyQT5 QGIS Plugin to wipe out all xyz connections available
> in QGS projects.
>
> I wrote the code below, but I am not achieving my goal and I did not
> understand the structure of xyz connections.
>
> def removeAllConnectionsXYZ(self):
> s = QSettings()
> xyz = 'qgis/connections-xyz'
> groupsXYZ = s.childGroups()
>
> for group in groupsXYZ:
> s.beginGroup(xyz)
> s.remove("")
> s.endGroup()
> self.dlg.wipeAllConnectionsXyz.clicked.connect(
> self.removeAllConnectionsXYZ)
>
>
>
>
> # Any comment will be very appreciated.
>
> #Thank you for your time in advance
>
> #Julierme
> ___
> 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] PyQGIS: wipe all xyz connections

2020-09-23 Thread 1520 gis
Dear all,

I am writing a PyQT5 QGIS Plugin to wipe out all xyz connections available
in QGS projects.

I wrote the code below, but I am not achieving my goal and I did not
understand the structure of xyz connections.

def removeAllConnectionsXYZ(self):
s = QSettings()
xyz = 'qgis/connections-xyz'
groupsXYZ = s.childGroups()

for group in groupsXYZ:
s.beginGroup(xyz)
s.remove("")
s.endGroup()
self.dlg.wipeAllConnectionsXyz.clicked.connect(
self.removeAllConnectionsXYZ)




# Any comment will be very appreciated.

#Thank you for your time in advance

#Julierme
___
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