[prev in list] [next in list] [prev in thread] [next in thread] 

List:       qgis-user
Subject:    Re: [Qgis-user] PyQGIS: wipe all xyz connections
From:       1520 gis <juliermeopensourcedeveloper () gmail ! com>
Date:       2020-09-23 17:45:03
Message-ID: CAKTKyJKvXgWCzPowME_6rx2htjnHf_HLRkq0n+0i_3SrPNQnCA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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 <epurpur@gmail.com> 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 <
> juliermeopensourcedeveloper@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
>
>

[Attachment #5 (text/html)]

<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:&quot;Droid \
Sans Mono&quot;,monospace,monospace,&quot;Droid Sans \
Fallback&quot;;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)">&#39;qgis/connections-xyz&#39;</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)">&quot;&quot;</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 &lt;<a href="mailto:epurpur@gmail.com">epurpur@gmail.com</a>&gt; \
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,&quot;Lucida \
Console&quot;,&quot;Liberation Mono&quot;,&quot;DejaVu Sans \
Mono&quot;,&quot;Bitstream Vera Sans Mono&quot;,&quot;Courier \
New&quot;,monospace,sans-serif;font-size:13px;white-space:pre-wrap;background-color:rgb(228,230,232)">for \
group in getGroupXYZ(self):  NameError: name &#39;getGroupXYZ&#39; 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 &lt;<a href="mailto:juliermeopensourcedeveloper@gmail.com" \
target="_blank">juliermeopensourcedeveloper@gmail.com</a>&gt; \
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:&quot;Droid \
Sans Mono&quot;,monospace,monospace,&quot;Droid Sans \
Fallback&quot;;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)">&#39;qgis/connections-xyz&#39;</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)">&quot;&quot;</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>


[Attachment #6 (text/plain)]

_______________________________________________
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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic