How to write a QGIS-plugin to be used in IntraMaps Roam 2.4.0?

المشرف العام

Administrator
طاقم الإدارة
I know some python, but I have never written a plugin for QGIS nor Roam before.I like to be able to turn layers on/off in RoamI have read the Roam's wiki, and I have managed to make a plugin called "Tull Plugin" available in the left meny in Roam.I have found some example code of how to show the legend and to turn layers on/off and tried it in the QGIS Python console with success (I'm using QGIS Desktop 2.8.2, python 2.7).So far nothing happens when I click on my plugin in Roam (quite naturally) since I don't know how to write the correct code in def __init__(self, api, parent=None):. I'm struggeling in implementing the example code:

from qgis.gui import *root = QgsProject.instance().layerTreeRoot()model = QgsLayerTreeModel(root)model.setFlag(QgsLayerTreeModel.AllowNodeReorder)model.setFlag(QgsLayerTreeModel.AllowNodeChangeVisibility)view = QgsLayerTreeView()# view = iface.layerTreeView()view.setModel(model)view.show()into my class TullPlugin in the tull_plugin.py:

from qgis.core import *from qgis.gui import *from qgis.utils import ifacefrom PyQt4.QtCore import *from PyQt4.QtGui import QWidgetfrom roam.api.plugins import Pageclass TullPlugin(QWidget, Page): title = "Tull Plugin" def __init__(self, api, parent=None): ....???Just copying the code into the def __init__ is not working. When using the exact code the plugin just starts but nothing happens (logical since no project is assigned?) and when using the iface-variant, "Loading project" goes on forever ("freezes") in Roam.

I have studied the search-plugin in Roam, but I'm still pretty clueless.

Any help is appreciated.



أكثر...
 
أعلى