[Qgis-developer] Qgis standalone apps
Massimo Di Stefano
massimodisasha at yahoo.it
Wed Sep 15 08:58:04 EDT 2010
Hi Giuseppe,
i tried with the "args" variable,
i have :
MacBook-Pro-15-di-sasha:~ sasha$ python /qgistry.py
Traceback (most recent call last):
File "/qgistry.py", line 66, in <module>
app = MainApp(sys.args)
AttributeError: 'module' object has no attribute 'args'
so i tried also without the "args" value,
what i'm missing ?
thanks to help me,
Massimo.
Il giorno 15/set/2010, alle ore 14.16, Giuseppe Sucameli ha scritto:
> Hi Massimo,
> as I wrote to you:
>
> class MainApp(QApplication):
> def __init__(self, args):
> QApplication.__init__(self, args)
> wdg = MyWdg()
> wdg.show()
> self.exec_()
>
> if __name__ == "__main__":
> import sys
> app = MainApp(sys.args)
>
> That is, you missed the "args" variable ;)
> Cheers.
>
>
> On Wed, Sep 15, 2010 at 1:52 PM, Massimo Di Stefano <massimodisasha at yahoo.it> wrote:
> sorry, i correct the link to the code i'm tring.
> my apologize :-/
>
> this one should work :
>
>> http://www.geofemengineering.it/data/qgistry.py
>
> Il giorno 15/set/2010, alle ore 12.21, Massimo Di Stefano ha scritto:
>
>> Hello All,
>>
>>
>> i'm tring to apply the changes you suggest me .. but with no good results
>> (again my fault)
>>
>> i tried to change the code to :
>>
>> http://www.geogemengineering.it/data/qgistry.py
>>
>> but i got :
>>
>> python /qgistry.py
>> Traceback (most recent call last):
>> File "/qgistry.py", line 68, in <module>
>> app = MainApp()
>> File "/qgistry.py", line 61, in __init__
>> QApplication.__init__(self)
>> TypeError: arguments did not match any overloaded call:
>> QApplication(list-of-str): not enough arguments
>> QApplication(list-of-str, bool): not enough arguments
>> QApplication(list-of-str, QApplication.Type): not enough arguments
>>
>>
>> can you help me to have it running ?
>>
>> thanks a lot !!!
>>
>> Massimo.
>>
>>
>> Il giorno 10/set/2010, alle ore 02.07, qgis-developer-request at lists.osgeo.org ha scritto:
>>
>>> Hi Massimo,
>>>
>>> On Fri, Sep 10, 2010 at 12:10 AM, Massimo Di Stefano <
>>> massimodisasha at yahoo.it> wrote:
>>>
>>>> Hi All,
>>>>
>>>> i'm tring to start some coding on the qgis api
>>>> i'm on osx 10.6.4 running qgis 1.6
>>>>
>>>> following the example from :
>>>>
>>>>
>>>>
>>>> http://mapserver.sk/~wonder/qgis/html/canvas.html#using-map-tools-with-canvas<http://mapserver.sk/%7Ewonder/qgis/html/canvas.html#using-map-tools-with-canvas>
>>>>
>>>> it works fine if i call it from a qgis-python shell
>>>>
>>>> but i tried to make small changes to have it running as a standalone
>>>> application,
>>>>
>>>> i eliminated the "layer" from the init line :
>>>>
>>>> QMainWindow.__init__(self)
>>>>
>>>> used a custom extent :
>>>>
>>>> self.canvas.setExtent('15.1845401903089403,40.6214856769878665 :
>>>> 15.2339879807105998,40.6477493100907381')
>>>>
>>>> and commented out the line :
>>>>
>>>> #self.canvas.setLayerSet( [ QgsMapCanvasLayer(layer) ] )
>>>>
>>>> then from a standard python shell, i tried :
>>>>
>>>>>>> import mywnd
>>>>>>> dir(mywnd)
>>>> ['MyWnd', 'QAction', 'QMainWindow', 'QString', 'QgisInterface',
>>>> 'QgsAnnotationItem', 'QgsColorButton', 'QgsColorButtonV2',
>>>> 'QgsComposerView', 'QgsEncodingFileDialog', 'QgsFormAnnotationItem',
>>>> 'QgsGenericProjectionSelector', 'QgsLegendInterface', 'QgsMapCanvas',
>>>> 'QgsMapCanvasItem', 'QgsMapCanvasLayer', 'QgsMapCanvasMap',
>>>> 'QgsMapCanvasSnapper', 'QgsMapOverviewCanvas', 'QgsMapTip', 'QgsMapTool',
>>>> 'QgsMapToolEmitPoint', 'QgsMapToolPan', 'QgsMapToolZoom',
>>>> 'QgsMessageViewer', 'QgsProjectBadLayerGuiHandler', 'QgsProjectionSelector',
>>>> 'QgsQuickPrint', 'QgsRendererV2PropertiesDialog', 'QgsRendererV2Widget',
>>>> 'QgsRubberBand', 'QgsStyleV2ManagerDialog', 'QgsSymbolLayerV2Widget',
>>>> 'QgsSymbolV2PropertiesDialog', 'QgsSymbolV2SelectorDialog',
>>>> 'QgsTextAnnotationItem', 'QgsVertexMarker', 'Qt', 'SIGNAL', '__builtins__',
>>>> '__doc__', '__file__', '__name__', '__package__']
>>>>>>> w = mywnd.MyWnd()
>>>> QWidget: Must construct a QApplication before a QPaintDevice
>>>> Abort trap
>>>>
>>> the MyWnd is a QWidget.
>>>
>>> You must create a QApplication instance and only after this you can
>>> show widgets within it.
>>>
>>> Here an example (main.py):
>>>
>>>
>>> from PyQt4.QtGui import QApplication
>>> from mywdg import MyWdg
>>>
>>> class MainApp(QApplication):
>>> def __init__(self, args):
>>> QApplication.__init__(self, args)
>>> wdg = MyWdg()
>>> wdg.show()
>>> self.exec_()
>>>
>>> if __name__ == "__main__":
>>> import sys
>>> app = MainApp(sys.args)
>>>
>>>
>>> Then open a terminal and run: python main.py
>>> and if all went fine you can see your widget.
>>>
>>> Cheers.
>>>
>>>
>>>>
>>>> it give me a python crash ... obviously i'm missing something basilar,
>>>>
>>>> have you any clue on what i need to change to have the example working
>>>> outside qgis ?
>>>>
>>>>
>>>> thanks a lot !!!
>>>>
>>>> regards,
>>>>
>>>> Massimo
>>
>
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
>
>
> --
> Giuseppe Sucameli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20100915/b4b9c952/attachment-0001.html
More information about the Qgis-developer
mailing list