Toggle Button

I have two stage toggle button in my project, which basically controls a valve to select the tank. I would like to get the label changed on the button based on my tank selection. How do I assign the tag or property to this?

On the 2 State Toggle button, the text is controlled by styles (as is foreground and background color).
In the Property Editor, select All for the filter properties. Now you will be able to change the text based on state, but not via a property or tag.

If it is driven from a tag, one way would be to create a new label that will eventually be hidden from the end user.
Then add the following code to the Event Handler -> property change of that label. Then everytime the tag changes, the label would update the text on the button.

#Get the current styles from the button.
data = event.source.parent.getComponent('2 State Toggle').styles
#Check which tank is selected.
t = 'Add your tag or property here.'
#Set the text to reflect the tank selected.
data = system.dataset.setValue(data, 0, 'text', 'Tank '+ t +' OFF')
data = system.dataset.setValue(data, 1, 'text', 'Tank '+ t +' ON')
event.source.parent.getComponent('2 State Toggle').styles = data

If your tag or property is anything other than a string, you will have to convert it.

tag = system.tag.read("my tag here")
t = str(tag.value)

Hope this helps!

Cheers,
Chris

Cris,
I know what you are saying, but the problem is how can I change the text based on the status. I can change only the current status text. How about the second status, how do I change the second text. it has the option for only one text.,…

What second text are you referring to? The code below changes both the On and Off state on the button.

#Set the text to reflect the tank selected.
data = system.dataset.setValue(data, 0, 'text', 'Tank '+ t +' OFF')
data = system.dataset.setValue(data, 1, 'text', 'Tank '+ t +' ON')

Please explain further.

Cheers,
Chris