How can I make the feature as a global variable?
import fmeobjects
import json
import matplotlib.pyplot as plt
from matplotlib.widgets import Button
from descartes import PolygonPatch
def checkViewer(feature):
BLUE = '#6699cc'
geometry = feature.getAttribute('_geometry')
geoJson = json.loads(geometry)
fig = plt.figure()
ax = fig.gca()
ax.add_patch(PolygonPatch(geoJson, fc=BLUE, ec=BLUE, alpha=0.5, zorder=2 ))
ax.axis('scaled')
callback = Index()
axprev = plt.axes([0.7, 0.05, 0.1, 0.075])
axnext = plt.axes([0.81, 0.05, 0.1, 0.075])
bnext = Button(axnext, 'Garder')
bnext.on_clicked(callback.garder)
bprev = Button(axprev, 'Rejeter')
bprev.on_clicked(callback.rejeter)
plt.show()
class Index():
def __init__(self):
self.feature = feature
def gader(self, event):
plt.close()
feature.setAttribute('check', "yes") #this is not working because feature is not global
def rejeter(self, event):
plt.close()
feature.setAttribute('check', "no") #this is not working