Panda3D Manual: DirectWaitBar
<<prev | top | next>> |
DirectWaitBars are similar to status bars; use them to indicate a slow process gradually completing (e.g. a loading screen). It has various options for both the background bar and the loading bar that fills up as the process progresses. You can call finish() to automatically fill up the bar, or use:
    myWaitBar['value'] = number
to set the value (it ranges from 0 to 100 by default).
Keyword | Definition | Value
value | Initial value of the loading bar (from 0 to 100) | Number
range | The maximum value of the loading bar | Number
barColor | The color of the loading bar | (R,G,B,A)
barRelief | The relief appearance of the loading bar | SUNKEN or RAISED
barBorderWidth | If barRelief is SUNKEN, RAISED, GROOVE, or RIDGE, changes the size of the loading bar's bevel | (Width,Height)
relief | The relief appearance of the background bar | SUNKEN or RAISED
## Example
    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)

    #create a frame
    frame = DirectFrame(text="main",scale=0.001)
    #add button
    bar = DirectWaitBar(text = "" , value=50,pos=(0,.4,.4))

    #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()
<<prev | top | next>> |