[SOLVED]image destroy doesn't work

Why the following doesn’t work?

I’m getting an error: global name ‘np’ is not defined.

class BttnPrss(DirectObject):
	def __init__(self):
		self.accept("p",self.addbg)
		self.accept("o",self.rembg)
	def addbg(self):
		np=OnscreenImage('image.jpg')
		np.setPos(0, 1, 0.8)
    	return np
	def rembg(self):
		np.destroy()
		return

Replace “np” with “self.np”, and this snippet will work.

EDIT: Post #150! :slight_smile:

Yes, that solves it. Many thanks!