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, <div><br></div><div>i tried with the &quot;args&quot; variable, </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>  File &quot;/qgistry.py&quot;, line 66, in &lt;module&gt;</div><div>    app = MainApp(sys.args)</div><div>AttributeError: &#39;module&#39; object has no attribute &#39;args&#39;</div>

</div><div><br></div><div><br></div><div>so i tried also without the &quot;args&quot; value,</div><div>what i&#39;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;">    def __init__(self, args):</span><br style="font-family: courier new,monospace;">



<span style="font-family: courier new,monospace;">        QApplication.__init__(self, args)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        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;">        wdg.show()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        self.exec_()</span><br><br><span style="font-family: courier new,monospace;">if __name__ == &quot;__main__&quot;:</span><br>




        import sys<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    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 &quot;args&quot; 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&#39;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&#39;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 : </div><div><br></div><div><div>python /qgistry.py</div><div>




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




<div>TypeError: arguments did not match any overloaded call:</div><div>  QApplication(list-of-str): not enough arguments</div><div>  QApplication(list-of-str, bool): not enough arguments</div><div>  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&#39;m tring to start some coding on the qgis api<br></blockquote><blockquote type="cite">i&#39;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 &quot;layer&quot; 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(&#39;15.1845401903089403,40.6214856769878665 :<br></blockquote><blockquote type="cite">15.2339879807105998,40.6477493100907381&#39;)<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">[&#39;MyWnd&#39;, &#39;QAction&#39;, &#39;QMainWindow&#39;, &#39;QString&#39;, &#39;QgisInterface&#39;,<br></blockquote><blockquote type="cite">&#39;QgsAnnotationItem&#39;, &#39;QgsColorButton&#39;, &#39;QgsColorButtonV2&#39;,<br>




</blockquote><blockquote type="cite">&#39;QgsComposerView&#39;, &#39;QgsEncodingFileDialog&#39;, &#39;QgsFormAnnotationItem&#39;,<br></blockquote><blockquote type="cite">&#39;QgsGenericProjectionSelector&#39;, &#39;QgsLegendInterface&#39;, &#39;QgsMapCanvas&#39;,<br>




</blockquote><blockquote type="cite">&#39;QgsMapCanvasItem&#39;, &#39;QgsMapCanvasLayer&#39;, &#39;QgsMapCanvasMap&#39;,<br></blockquote><blockquote type="cite">&#39;QgsMapCanvasSnapper&#39;, &#39;QgsMapOverviewCanvas&#39;, &#39;QgsMapTip&#39;, &#39;QgsMapTool&#39;,<br>




</blockquote><blockquote type="cite">&#39;QgsMapToolEmitPoint&#39;, &#39;QgsMapToolPan&#39;, &#39;QgsMapToolZoom&#39;,<br></blockquote><blockquote type="cite">&#39;QgsMessageViewer&#39;, &#39;QgsProjectBadLayerGuiHandler&#39;, &#39;QgsProjectionSelector&#39;,<br>




</blockquote><blockquote type="cite">&#39;QgsQuickPrint&#39;, &#39;QgsRendererV2PropertiesDialog&#39;, &#39;QgsRendererV2Widget&#39;,<br></blockquote><blockquote type="cite">&#39;QgsRubberBand&#39;, &#39;QgsStyleV2ManagerDialog&#39;, &#39;QgsSymbolLayerV2Widget&#39;,<br>




</blockquote><blockquote type="cite">&#39;QgsSymbolV2PropertiesDialog&#39;, &#39;QgsSymbolV2SelectorDialog&#39;,<br></blockquote><blockquote type="cite">&#39;QgsTextAnnotationItem&#39;, &#39;QgsVertexMarker&#39;, &#39;Qt&#39;, &#39;SIGNAL&#39;, &#39;__builtins__&#39;,<br>




</blockquote><blockquote type="cite">&#39;__doc__&#39;, &#39;__file__&#39;, &#39;__name__&#39;, &#39;__package__&#39;]<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>   def __init__(self, args):<br>       QApplication.__init__(self, args)<br>       wdg = MyWdg()<br>       wdg.show()<br>       self.exec_()<br><br>if __name__ == &quot;__main__&quot;:<br>




       import sys<br>   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&#39;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>