DirectFrame with multiple geoms/states?

Hi David,

I’m sorry that I have waisted your time. It DOES work fine. I don’t know how I tested it in the first place and came to the conclusion that it wouldn’t work.

Anyway, maybe it’s beneficial for others, so here my quick test that demonstrates that DirectFrame objects can have multiple states and switch between them:

import direct.directbase.DirectStart
from direct.gui.DirectGui import *
from direct.interval.IntervalGlobal import *

# function to switch the states of DirectGui Widget
def switchState(frame, statenum):
    frame.guiItem.setState(statenum)

smiley = loader.loadModel("smiley.egg.pz")
box = loader.loadModel("box.egg.pz")

# add some frames with a single state - I merely display them for reference, to check how my two states will look like..
f1 = DirectFrame(relief = None, geom = smiley, scale = 0.1, pos = (-1,0,0))
f2 = DirectFrame(relief = None, geom = box, scale = 0.1, pos = (1,0,0))

# frame with multiple states
f3 = DirectFrame(relief = None, geom = (box, smiley), numStates = 2, scale = 0.1)

# cerate an interval that switches the state every second
interval = Sequence(Wait(1.0), Func(switchState, f3, 1), Wait(1.0), Func(switchState, f3, 0))
interval.loop()

#run!
run()