self.PandaFrameBookButton = []
self.PandaFrameBookButton.append(DirectRadioButton(scale=0.05,frameColor=(0.3,0.3,0.3,0.3),boxImage=None,frameSize=(-1.5,4.8,-0.5,1.1),
command=self.clickBook,extraArgs=[0],relief=1,text_align=TextNode.ALeft,pos=(-1.3,0,0.6),text = '身体'))
self.PandaFrameBookButton.append(DirectRadioButton(scale=0.05,frameColor=(0.3,0.3,0.3,0.0),boxImage=None,frameSize=(-1.5,4.8,-0.5,1.1),
command=self.clickBook,extraArgs=[1],relief=1,text_align=TextNode.ALeft,pos=(-1.3,0,0.5),text = '头发'))
self.PandaFrameBookButton.append(DirectRadioButton(scale=0.05,frameColor=(0.3,0.3,0.3,0.0),boxImage=None,frameSize=(-1.5,4.8,-0.5,1.1),
command=self.clickBook,extraArgs=[2],relief=1,text_align=TextNode.ALeft,pos=(-1.3,0,0.4),text = '眉毛/眼睛'))
.
.
.
def clickBook(self, event):
for button in self.PandaFrameBookButton:
button.setFrameColor(0.3,0.3,0.3,0.0)
self.PandaFrameBookButton[event].setFrameColor(0.3,0.3,0.3,0.3)
When I run it:
File "CharacterEditor.py", line 280, in __init__
command=self.clickBook,extraArgs=[0],relief=1,text_align=TextNode.ALeft,pos=(-1.3,0,0.6),text = '身体'))
File "/usr/share/panda3d/direct/gui/DirectRadioButton.py", line 90, in __init__
self.check()
File "/usr/share/panda3d/direct/gui/DirectRadioButton.py", line 206, in check
apply(self['command'], self['extraArgs'])
File "CharacterEditor.py", line 408, in clickBook
self.PandaFrameBookButton[event].setFrameColor(0.3,0.3,0.3,0.3)
IndexError: list index out of range
When the PandaFrameBookButton be created, the clickBook be runed automated. Why?
By the way, I use panda3d1.8_1.8.0+cvs20120124~natty230_amd64.deb.