Hi, thanks so much for the help. Right now the AtlasListener is throwing up a
NameError: name 'QObject' is not defined I looked up the API and when instantiating the AtlasListener, I can pass a QObject into the constructor. What QObject should I put in there? Thanks On Thu, Dec 15, 2016 at 7:35 PM, Nyall Dawson <[email protected]> wrote: > On 14 December 2016 at 13:42, Shawn Tse <[email protected]> wrote: >> Thanks, that looks like exactly the kind of function that I'm looking >> for. I'm using QGIS 2.18.0, I'm wondering, is there any way to use >> this function without having to select a menu item in the the plugin? >> >> I'm not sure how to get started, because most of the existing plugins >> seem to be activated by a menu item or a toolbar button in the main >> editor instead of via the atlas interface. >> >> Thank you and I really appreciate the help! > > Hi Shawn, > > Have a read up on how signals and slots work in PyQt. Basically you > can listen out for the signal and get it to trigger a function in your > python class. Untested psuedocode below: > > class AtlasListener(QObject): > def featureChanged(self, feature): > print('new feature: {}'.format(feature.id()) > > def setComposition(self, composition): > > composition.atlasComposition().featureChanged.connect(self.featureChanged) > > l=AtlasListener() > l.setComposition(iface.activeComposers()[0].composition()) > > > Nyall > > >> >> On Mon, Dec 12, 2016 at 11:02 PM, Nyall Dawson <[email protected]> >> wrote: >>> >>> >>> On 13 Dec 2016 4:44 PM, "Shawn Tse" <[email protected]> wrote: >>> >>> Hi all, >>> >>> I'm interested in being able to make graphs that update depending on >>> what the active feature in the atlas is. I know some python and a >>> little bit of the QGIS API, but I'm curious - is there some sort of >>> listener function for the atlas that gets called whenever the Preview >>> Atlas/Prev Feature/Next Feature/First Feature/Last Feature buttons are >>> pressed? >>> >>> >>> Try QgsAtlasComposition::featureChanged. See >>> https://qgis.org/api/classQgsAtlasComposition.html#ab1a15fdb6d20ebb1254ebb6714254fac >>> >>> Nyall >>> >>> >>> What I eventually want to do is to manipulate the node items that were >>> created in a recent updated version of QGIS, and use them to make a >>> line graph, gridlines, etc. >>> >>> I'm hoping to draw the data directly from the shapefiles themselves or >>> from a .csv file. >>> >>> I originally tried to use an expression in a text box to do this, but >>> it seems that expressions are unable to use custom functions to >>> manipulate the composer. So I'm hoping that there's some sort of >>> Listener method. >>> >>> Thanks. >>> _______________________________________________ >>> Qgis-developer mailing list >>> [email protected] >>> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer >>> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer >>> >>> >> _______________________________________________ >> Qgis-developer mailing list >> [email protected] >> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer >> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer _______________________________________________ Qgis-developer mailing list [email protected] List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
