<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Thanks Giuseppe,<div><br></div><div>it works fine, no crash on exit</div><div>all as aspected :-)</div><div><br></div><div><br></div><div>happy to start to code on qgis-python side :-)</div><div><br></div><div>my best regrads, and happy coding for the hackfest !!!</div><div><br></div><div><br></div><div>Ciao,</div><div><br></div><div>Massimo.</div><div><br></div><div><br></div><div><br></div><div>Il giorno 15/set/2010, alle ore 15.33, Giuseppe Sucameli ha scritto:</div><div><div><br class="Apple-interchange-newline"><blockquote type="cite">oops... sys.argv :)<br><br><div class="gmail_quote">On Wed, Sep 15, 2010 at 2:58 PM, Massimo Di Stefano <span dir="ltr">&lt;<a href="mailto:massimodisasha@yahoo.it">massimodisasha@yahoo.it</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div style="word-wrap: break-word;">Hi Giuseppe,&nbsp;<div><br></div><div>i tried with the "args" variable,&nbsp;</div><div>i have :</div><div><br></div><div><br></div><div><div>MacBook-Pro-15-di-sasha:~ sasha$ python /qgistry.py</div>

<div class="im"><div>Traceback (most recent call last):</div></div><div>&nbsp;&nbsp;File "/qgistry.py", line 66, in &lt;module&gt;</div><div>&nbsp;&nbsp; &nbsp;app = MainApp(sys.args)</div><div>AttributeError: 'module' object has no attribute 'args'</div>

</div><div><br></div><div><br></div><div>so i tried also without the "args" value,</div><div>what i'm missing ?</div><div><br></div><div>thanks to help me,</div><div><br></div><div>Massimo.</div><div><br></div>

<div><br><div><div>Il giorno 15/set/2010, alle ore 14.16, Giuseppe Sucameli ha scritto:</div><div><div></div><div class="h5"><br><blockquote type="cite">Hi Massimo,<br>as I wrote to you:<br><br><span style="font-family: courier new,monospace;">class MainApp(QApplication):</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; def __init__(self, args):</span><br style="font-family: courier new,monospace;">



<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; QApplication.__init__(self, args)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wdg = </span><span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;">MyWdg()</span><br style="font-family: courier new,monospace;">





<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wdg.show()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.exec_()</span><br><br><span style="font-family: courier new,monospace;">if __name__ == "__main__":</span><br>




&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; import sys<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; app = </span><span style="font-family: courier new,monospace;">MainApp(</span><span style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">sys.args</span>)<br>




</span><br>That is, you missed the "args" variable ;)<br>Cheers.<br><br><br><div class="gmail_quote">On Wed, Sep 15, 2010 at 1:52 PM, Massimo Di Stefano <span dir="ltr">&lt;<a href="mailto:massimodisasha@yahoo.it" target="_blank">massimodisasha@yahoo.it</a>&gt;</span> wrote:<br>




<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;">sorry, i correct the link to the code i'm tring.<div>




my apologize :-/</div><div><br></div><div>this one should work :</div><div><br></div><div><blockquote type="cite"><div style="word-wrap: break-word;"><div><a href="http://www.geofemengineering.it/data/qgistry.py" target="_blank">http://www.geofemengineering.it/data/qgistry.py</a></div>




</div></blockquote><div><br><div><div>Il giorno 15/set/2010, alle ore 12.21, Massimo Di Stefano ha scritto:</div><div><div></div><div><br><blockquote type="cite"><div style="word-wrap: break-word;"><div>Hello All,</div>
<div><br></div><div><br></div><div>i'm tring to apply the changes you suggest me .. but with no good results</div><div>(again my fault)</div><div><br></div><div>i tried to change the code to :</div><div><br></div><div>




<a href="http://www.geogemengineering.it/data/qgistry.py" target="_blank">http://www.geogemengineering.it/data/qgistry.py</a></div><div><br></div><div>but i got :&nbsp;</div><div><br></div><div><div>python /qgistry.py</div><div>




Traceback (most recent call last):</div><div>&nbsp;&nbsp;File "/qgistry.py", line 68, in &lt;module&gt;</div><div>&nbsp;&nbsp; &nbsp;app = MainApp()</div><div>&nbsp;&nbsp;File "/qgistry.py", line 61, in __init__</div><div>&nbsp;&nbsp; &nbsp;QApplication.__init__(self)</div>




<div>TypeError: arguments did not match any overloaded call:</div><div>&nbsp;&nbsp;QApplication(list-of-str): not enough arguments</div><div>&nbsp;&nbsp;QApplication(list-of-str, bool): not enough arguments</div><div>&nbsp;&nbsp;QApplication(list-of-str, QApplication.Type): not enough arguments</div>




</div><div><br></div><div><br></div><div>can you help me to have it running ?</div><div><br></div><div>thanks a lot !!!</div><div><br></div><div>Massimo.</div><div><br></div><br><div><div>Il giorno 10/set/2010, alle ore 02.07, <a href="mailto:qgis-developer-request@lists.osgeo.org" target="_blank">qgis-developer-request@lists.osgeo.org</a> ha scritto:</div>




<br><blockquote type="cite">Hi Massimo,<br><br>On Fri, Sep 10, 2010 at 12:10 AM, Massimo Di Stefano &lt;<br><a href="mailto:massimodisasha@yahoo.it" target="_blank">massimodisasha@yahoo.it</a>&gt; wrote:<br><br><blockquote type="cite">




Hi All,<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">i'm tring to start some coding on the qgis api<br></blockquote><blockquote type="cite">i'm on osx 10.6.4 running qgis 1.6<br>




</blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">following the example from :<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">




<br></blockquote><blockquote type="cite"><a href="http://mapserver.sk/%7Ewonder/qgis/html" target="_blank">http://mapserver.sk/~wonder/qgis/html</a>/canvas.html#using-map-tools-with-canvas&lt;<a href="http://mapserver.sk/%7Ewonder/qgis/html/canvas.html#using-map-tools-with-canvas" target="_blank">http://mapserver.sk/%7Ewonder/qgis/html/canvas.html#using-map-tools-with-canvas</a>&gt;<br>




</blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">it works fine if i call it from a qgis-python shell<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">but i tried to make small changes to have it running as a standalone<br>




</blockquote><blockquote type="cite">application,<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">i eliminated the "layer" from the init line :<br></blockquote><blockquote type="cite">




<br></blockquote><blockquote type="cite">QMainWindow.__init__(self)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">used a custom extent :<br></blockquote><blockquote type="cite"><br></blockquote>




<blockquote type="cite">self.canvas.setExtent('15.1845401903089403,40.6214856769878665 :<br></blockquote><blockquote type="cite">15.2339879807105998,40.6477493100907381')<br></blockquote><blockquote type="cite"><br>




</blockquote><blockquote type="cite">and commented out the line :<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">#self.canvas.setLayerSet( [ QgsMapCanvasLayer(layer) ] )<br></blockquote>



<blockquote type="cite">
<br></blockquote><blockquote type="cite">then from a standard python shell, i tried :<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">




import mywnd<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">dir(mywnd)<br></blockquote></blockquote></blockquote></blockquote>




<blockquote type="cite">['MyWnd', 'QAction', 'QMainWindow', 'QString', 'QgisInterface',<br></blockquote><blockquote type="cite">'QgsAnnotationItem', 'QgsColorButton', 'QgsColorButtonV2',<br>




</blockquote><blockquote type="cite">'QgsComposerView', 'QgsEncodingFileDialog', 'QgsFormAnnotationItem',<br></blockquote><blockquote type="cite">'QgsGenericProjectionSelector', 'QgsLegendInterface', 'QgsMapCanvas',<br>




</blockquote><blockquote type="cite">'QgsMapCanvasItem', 'QgsMapCanvasLayer', 'QgsMapCanvasMap',<br></blockquote><blockquote type="cite">'QgsMapCanvasSnapper', 'QgsMapOverviewCanvas', 'QgsMapTip', 'QgsMapTool',<br>




</blockquote><blockquote type="cite">'QgsMapToolEmitPoint', 'QgsMapToolPan', 'QgsMapToolZoom',<br></blockquote><blockquote type="cite">'QgsMessageViewer', 'QgsProjectBadLayerGuiHandler', 'QgsProjectionSelector',<br>




</blockquote><blockquote type="cite">'QgsQuickPrint', 'QgsRendererV2PropertiesDialog', 'QgsRendererV2Widget',<br></blockquote><blockquote type="cite">'QgsRubberBand', 'QgsStyleV2ManagerDialog', 'QgsSymbolLayerV2Widget',<br>




</blockquote><blockquote type="cite">'QgsSymbolV2PropertiesDialog', 'QgsSymbolV2SelectorDialog',<br></blockquote><blockquote type="cite">'QgsTextAnnotationItem', 'QgsVertexMarker', 'Qt', 'SIGNAL', '__builtins__',<br>




</blockquote><blockquote type="cite">'__doc__', '__file__', '__name__', '__package__']<br></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">




w = mywnd.MyWnd()<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite">QWidget: Must construct a QApplication before a QPaintDevice<br></blockquote><blockquote type="cite">Abort trap<br></blockquote>




<blockquote type="cite"><br></blockquote>the MyWnd is a QWidget.<br><br>You must create a QApplication instance and only after this you can<br>show widgets within it.<br><br>Here an example (main.py):<br><br><br>from PyQt4.QtGui import QApplication<br>




from mywdg import MyWdg<br><br>class MainApp(QApplication):<br>&nbsp;&nbsp;&nbsp;def __init__(self, args):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;QApplication.__init__(self, args)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wdg = MyWdg()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wdg.show()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.exec_()<br><br>if __name__ == "__main__":<br>




&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;import sys<br>&nbsp;&nbsp;&nbsp;app = MainApp(sys.args)<br><br><br>Then open a terminal and run: python main.py<br>and if all went fine you can see your widget.<br><br>Cheers.<br><br><br><blockquote type="cite"><br></blockquote>



<blockquote type="cite">
it give me a python crash ... obviously i'm missing something basilar,<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">have you any clue on what i need to change to have the example working<br>




</blockquote><blockquote type="cite">outside qgis ?<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">thanks a lot !!!<br></blockquote><blockquote type="cite">




<br></blockquote><blockquote type="cite">regards,<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Massimo</blockquote></blockquote></div><br></div></blockquote></div></div></div><br></div>




</div></div><br>_______________________________________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Giuseppe Sucameli<br>
</blockquote></div></div></div><br></div></div></blockquote></div><br><br clear="all"><br>-- <br>Giuseppe Sucameli<br>
</blockquote></div><br></div></body></html>