I'm writing code that has two classes. The one class creates text elements for a 3-D environment. The other will group them together in that environment. What I'm trying to do is have the second class call instances of the first class. In other words, in def makeGroup
I want to be able to call an instance of class msg
. How would the coding be worded? Currently, the first class is inherited into the second, and then I'm trying to call the object self.text, but I don't know how I should refer to it. I don't believe I'm quite using inheritance correctly.
class msg:
def __init__(self,num,unit):
self.message = str(num) + ' ' + unit
self.num = num
self.text = viz.addText(self.message)
class msgGroup(msg):
def __init__(self,x,y,z):
self.msgLs=[]
self.ghostMsg= viz.addText('',pos=[x,y,z],color= [0.000, .9, 0.071])
self.msgLs.append(self.ghostMsg)
def makeGroup(self):
msg.text.setPosition([0,(len(self.msgLs)-1)*-1.5,0], viz.REL_PARENT)
self.msgLs.append(msg.text)