Deleting existing TextNodes from screen

So I’m trying to delete the existing batch of TextNodes to make room for new text nodes. Once the text nodes upload all you do is click on the next topic to pull up new links. Any clue how to achieve clearing the screen? I realize there is textobject.destroy() function however I’m not sure how I can go back to each node created in each postion.

from direct.showbase.ShowBase import ShowBase
from direct.showbase.DirectObject import DirectObject
from direct.showbase import DirectObject
from direct.gui.DirectGui import *
from direct.interval.IntervalGlobal import *
from panda3d.core import lookAt
import urllib2
from bs4 import BeautifulSoup
import numpy as np
import sys
import os
import math

Tag = np.empty((25), dtype=object)
tag=np.empty((150),dtype=object)
tags=np.empty((150),dtype=object)
NodeP = np.empty((25), dtype=object)
cos=math.cos
sin=math.sin
pi=math.pi
from direct.gui.OnscreenText import OnscreenText
from pandac.PandaModules import TextNode



def createText(n,Max,string):
	r=.9
	x=cos((2*pi*n)/Max)*r
	y=sin((2*pi*n)/Max)*r
	ybot=round(y,2)
	NodeP[n]=ybot
	textObject = OnscreenText(text = string, pos = (x, y,0), scale = 0.04)
	#text = TextNode('DebugConsole')
	#text.setText(string)
	#textNodePath = aspect2d.attachNewNode(text)
	#textNodePath.setScale(0.045)
	#textNodePath.setPos(x,0,y)
	
	#text.setFrameColor(1,1,1,1)
	#text.setFrameAsMargin(.2,.2,.2,.2)
	#text.setCardColor(1, .01, 0.01, .01)
	#text.setCardAsMargin(1, 1, 1, 1)
	#text.setCardDecal(True)
	

class Click(DirectObject.DirectObject):
  def __init__(self):
    self.accept('mouse1',self.Pos)
  def getString(self,i,y):
	global NextNode
	yin=NodeP[i]
	ytop=yin+.04
	while (yin<=ytop):
		if yin==y:
			#print tag[i]
			NextNode = tag[i]
		yin=yin+.01
	
  
  def Pos(self):
	global h
	x=base.mouseWatcherNode.getMouseX()
	y=base.mouseWatcherNode.getMouseY()
	y=round(y,2)
	
	
	if x>0:
		if y>0:
			for i in range(0,6):
				self.getString(i,y)
		if y<0:
			for i in range(14,20):
				self.getString(i,y)
	if x<0:
		if y>0:
			for i in range(5,11):
				self.getString(i,y)
		if y<0:
			for i in range(10,16):
				self.getString(i,y)				
	try:
		
		print NextNode	
		#print "preCircle"
		
		getCircle(NextNode)
	except:
		t=0
		print h
	h=h+1
	#print h
def getCircle(Search):
	
	print "IN"

	etf_page = "https://en.wikipedia.org/wiki/"+Search


	url = etf_page
	content = urllib2.urlopen(url).read()	
	soup = BeautifulSoup(content,"lxml")
	#l=len(soup.findAll("p"))
	para=soup.findAll("p")

	e=0 
	h=0
	t=0
	max=20

	for n in range(0,10):
		try:	
			l=para[n].findAll('a')
			for link in l:
				title= link.get('title')
				#print title
				if title:
					if "Help" in title:
						h=h+1
					else:
						tags[t]=title
						t=t+1
			if t==max:
				n=10
		except:
			e=e+1
	for a in range(0,max):
		tag[a]=tags[a].replace(" ","_")
		print tag[a]
	setCircle()

	
def setCircle():
	
	numN=20
	for i in range (0,numN):
		createText(i,numN,tags[i])
	

ans = raw_input('Start Search:  ')	

Search=ans.replace(" ","_")


base = ShowBase()
base.setBackgroundColor(0, 0, 250)
base.disableMouse()
base.camera.setPos(0, 0, 4)
base.camera.lookAt( 0, 0, 0 )				
global h
getCircle(Search)
h=0

Click()
	

base.run()

I’d suggest storing them in a list. (Or a dictionary, if you want to access them individually based on some identifier, such as a name.) Then, when you want to remove them, you simply iterate over the list and call “destroy” on each. That done, you clear the list, ready for the next batch to be stored within.

Aah seems so simple in hindsight. Never thought I could make an array out of the text objects. Works great