Doubt on this code direct button panda3d manual

i am a newbie to python so please help me…
this is from …
panda3d.org/manual/index.php/DirectCheckButton

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 setText(status):
if(status):
bk_text = “Checkbox Selected”
else:
bk_text = “Checkbox Not Selected”
textObject.setText(bk_text)

Add button

b = DirectCheckButton(text = “CheckButton” ,scale=.05,command=setText)

Run the tutorial

run()


in this program in the function call directObject.setText(bk_text) … bk_text is passed as parameter to function setText recursively
… am i rite there . and in the function DirectCheckButton(text = “CheckButton” ,scale=.05,command=setText) what is the role of argument command=setText … I am terribly confused…
and when i try to print status in the function definition i am always getting 1 or 0 printed as output in the command prompt … why is it when
i am passing a string (bk_text) as parameter which is accepted as argument by status i am not getting string typed… could any one point to me where is my interpretation wrong… Or is my interpretation an absolute blunder Even so any suggestive help would be a high helping hand to me … Thanks in advance[/url]

first of all. if you are pasting code please use the [ code ] tags. or all leading whitespaces (thus indentation) will be lost.

ah. no there is no recursion going on here. although there are 2 functions with the same name. one belongs to the textObject. and one belongs to you (as in you defined it globally).

the directCheckbutton calls the one which was defined globally which you are looking at in the code. which is then calling the textObject’s setText function.

OK Thank for your kindness to help me…
but still when i change a code like this

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 setText(status):
	if(status):
		bk_text = "Checkbox Selected"
                print status

	else:
		bk_text = "Checkbox Not Selected"
                print status
	textObject.setText(bk_text)  



        
 
# Add button
b = DirectCheckButton(text = "CheckButton" ,scale=.05,command=setText)
 
# Run the tutorial
run()

I get in the terminal as

DirectStart: Starting the game.
Known pipe types:
  wglGraphicsPipe
(all display modules loaded.)
1
0
1
0

on each mouse click on button …
Why is it not printing either Checkbox selected
or CheckBox unselected in the terminal…Thanx in advance

You’re asking it to print the checkbox’s status, which is either 1 (checked) or 0 (unchecked).

If you want it to print the words, then print bk_text