AWS Thinkbox Discussion Forums

Grabbing data from a check box

I am writing a submitter that has some check boxes in its GUI. I figured out querying the check box directly just returns a boolean.

newDialog.GetValue( "LightCheckBox" )

The above code snippet will return True or False depending if the box is checked.

How do I query the check box’s label? In my code, I check to see if a box is checked and then I want to grab the text right next to the box.

I’m not actually sure that’s possible. I checked the list of ScriptControl functions and GetValue() and GetValue() are all we’ve got for accessors there.

To avoid headaches down the road, it’s probably best you separate your display code from your control. That just means if you decide to add some extra text to your checkbox, you can avoid needing to change whatever’s using that value (which I used to to do all the time). The easy but verbose way of getting text depending on the value would be this:

text = "it was checked" if newDialog.GetValue( "LightCheckBox" ) else "it wasn't checked"

If you really want to avoid duplicating your work, you could store the label text in a variable and use it in both places.

Okay cool. In my current case, I do know what is in each check box, but that is really good information. I’ll keep it in my mind for the future. Thanks!

Privacy | Site terms | Cookie preferences