<div dir="ltr">Hi Erich Purpur,<div><br></div><div>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:</div><div><br></div><div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:24px;line-height:32px;white-space:pre"><div><span style="color:rgb(86,156,214)">def</span> <span style="color:rgb(220,220,170)">removeAllConnectionsXYZ</span>(<span style="color:rgb(156,220,254)">self</span>):</div><div>        s = QSettings()</div><div>        xyz = <span style="color:rgb(206,145,120)">'qgis/connections-xyz'</span></div><div>        groupsXYZ = s.childGroups()</div><div>        <span style="color:rgb(197,134,192)">for</span> group <span style="color:rgb(86,156,214)">in</span> groupsXYZ:</div><div>            s.beginGroup(xyz)</div><div>            s.remove(<span style="color:rgb(206,145,120)">""</span>)</div><div>            s.endGroup()</div><div><br></div><div><div style="line-height:32px"><div><span style="color:rgb(86,156,214)">self</span>.dlg.wipeAllConnectionsXyz.clicked.connect(</div><div>                <span style="color:rgb(86,156,214)">self</span>.removeAllConnectionsXYZ)</div><div><br></div><div># Kind regards</div><div><br></div><div># Julierme</div></div></div></div></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 23, 2020 at 1:54 PM Erich Purpur <<a href="mailto:epurpur@gmail.com">epurpur@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Is this regarding the following stackoverflow thread? <div><a href="https://gis.stackexchange.com/questions/374808/pyqt5-wipe-xyz-connections" target="_blank">https://gis.stackexchange.com/questions/374808/pyqt5-wipe-xyz-connections</a><br><br>If so, your error message as you posted it in StackOverflow is: </div><div><span style="color:rgb(36,39,41);font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;white-space:pre-wrap;background-color:rgb(228,230,232)">for group in getGroupXYZ(self):  NameError: name 'getGroupXYZ' is not defined</span><br></div><div><br></div><div>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.</div><div><br></div><div>-Erich</div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 23, 2020 at 11:38 AM 1520 gis <<a href="mailto:juliermeopensourcedeveloper@gmail.com" target="_blank">juliermeopensourcedeveloper@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Dear all,<div><br></div><div>I am writing a PyQT5 QGIS Plugin to wipe out all xyz connections available in QGS projects.</div><div><br></div><div>I wrote the code below, but I am not achieving my goal and I did not understand the structure of xyz connections.</div><div><br></div><div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:24px;line-height:32px;white-space:pre-wrap"><div><span style="color:rgb(86,156,214)">def</span> <span style="color:rgb(220,220,170)">removeAllConnectionsXYZ</span>(<span style="color:rgb(156,220,254)">self</span>):</div><div>        s = QSettings()</div><div>        xyz = <span style="color:rgb(206,145,120)">'qgis/connections-xyz'</span></div><div>        groupsXYZ = s.childGroups()</div><br><div>        <span style="color:rgb(197,134,192)">for</span> group <span style="color:rgb(86,156,214)">in</span> groupsXYZ:</div><div>            s.beginGroup(xyz)</div><div>            s.remove(<span style="color:rgb(206,145,120)">""</span>)</div><div>            s.endGroup()</div><div><div style="line-height:32px"><div><span style="color:rgb(86,156,214)">self</span>.dlg.wipeAllConnectionsXyz.clicked.connect(</div><div>                <span style="color:rgb(86,156,214)">self</span>.removeAllConnectionsXYZ)</div><div><br></div><div><br></div><div><br></div><div><br></div><div># Any comment will be very appreciated.</div><div><br></div><div>#Thank you for your time in advance</div><div><br></div><div>#Julierme</div></div></div></div></div></div>
_______________________________________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a></blockquote></div>
</blockquote></div>