Make sure to save the values of ¡°t¡± and ¡°m¡± so that later you can do
t.removePropertyListener(m)
with exactly the same values.
The easiest way to do that might be to make them member variables, i.e. self.t and self.m
Bob
On Feb 13, 2020, at 7:25 PM, ahouse3761 <trainmail1@...> wrote:
Hi all,
I have been trying to learn how to remove a listener from a script I cobbled together. The script makes a cut list based on a train crossing over an RFID reader. Cutlist generation works great. But then I want to stop the listener until I need it again. I looked at the scripting examples but I am not getting it. A snippit of the script is below but the full file is in the files being worked on area in the folder 'Allen House'.
I am using JMRI version 4.18.
Any help appreciated.
Regards,
Allen
def start(self, reporterName, memoryName, cutListName) :
# connect the object to the reporter, and start to work
print 'Start CutList'
print 'CutLIst # %s' % cutListName
self.Cutlist = cutListName
print self.Cutlist
self.memory = jmri.InstanceManager.memoryManagerInstance().provideMemory(memoryName)
# setup to be able to remove listener later
t = reporters.provideReporter(reporterName)
m = ReporterOperations2()
t.addPropertyChangeListener(m)
self.cm = jmri.jmrit.operations.rollingstock.cars.CarManager.instance()
self.em = jmri.jmrit.operations.rollingstock.engines.EngineManager.instance()
self.Cut_list = []
--
Bob Jacobsen
rgj1927@...