Hi,
I’m trying my best to understand the panda Direct Gui system. When I modify the code in the manual for DirectWaitBar and make the parent=render, the bar is messed up. It does draw, and you can zoom in, out, rotate it, etc. But it doesn’t show the bar properly. Any ideas?
import direct.directbase.DirectStart
from direct.gui.OnscreenText import OnscreenText
from direct.gui.DirectGui import *
from pandac.PandaModules import *
#add some text
bk_text = "This is my Demo"
textObject = OnscreenText(text = bk_text, pos = (0.95,-0.95),
scale = 0.07,fg=(1,0.5,0.5,1),align=TextNode.ACenter,mayChange=1)
#callback function to set text
def incBar(arg):
bar['value'] += arg
text = "Progress is:"+str(bar['value'])+'%'
textObject.setText(text)
bar['text'] = '%s / %s' % (arg, arg)
#create a frame
frame = DirectFrame(text="main",scale=0.001)
#add button
bar = DirectWaitBar(text = "0 / 0" , value=50,pos=(0,.4,.4), parent=render)
#create 4 buttons
button_1 = DirectButton(text="+1",scale=0.05,pos=(-.3,.6,0), command=incBar,extraArgs = [1])
button_10 = DirectButton(text="+10",scale=0.05,pos=(0,.6,0), command=incBar,extraArgs = [10])
button_m1 = DirectButton(text="-1",scale=0.05,pos=(0.3,.6,0), command=incBar,extraArgs = [-1])
button_m10 = DirectButton(text="-10",scale=0.05,pos=(0.6,.6,0), command=incBar,extraArgs = [-10])
#run the tutorial
run()
Thanks,
C