Visibility in Script -> visible = True but item doesn't show

To sum up, my question is this: why the script does not work in the invisibile component’s component to make the component visible?


Here is the details:

I have a Template named AToggleBit with a Multi-State Indicator (MSI) component inside. The MSI has 3 states:

0 = Error 1 = OK 2 = Unused

And then in the MSI, on propertyChange event, I create a script like this (note that this is my whole script):

[code]if event.propertyName == ‘state’: #if the state changes
stateValue = event.source.state #get the current MSI state Value
atogglebit = event.source.parent #get the template
rcont = atogglebit.parent.parent.parent #get the Root Container (please don’t bother the triple parent here, the rcont is obtained this way)
if rcont: #if root container found
ddown = rcont.getComponent(‘Dropdown’) #get Dropdown in the Root Container
if ddown: #if dropdown found
ddval = ddown.selectedValue #get the Dropdown Value

		#check template visibility
		visibility = stateValue == 0 or \
			(stateValue == 1 and ddval != 2) or \
			ddval == 0

		#just printing the values
		print "[", ddown.selectedStringValue, "] state: ", \
			"alarm" if stateValue == 0 \
			else "normal" if stateValue == 1 else "unused", \
			" visibility: ", visibility

		#assign template visibility
		atogglebit.visible = visibility #change the visibility of the template

[/code]

What the script in the MSI does is essential to show or to hide the AToggleBit Template.

Moreover, the script is only useful when the Template AToggleBit is placed in a Window with a Dropdown directly under the Root Container and where the Dropdown has following three value-string pairs:

0 = "All" 1 = "Used Only" 2 = "Active Only"

The script checks the Dropdown value and have the following visibility behavior:

Visible if:

  1. Its MSI is in “Error” (stateValue = 0), or
  2. Its MSI is “OK” (stateValue = 1) and the Dropdown value is NOT “Active Only” (ddval != 2), or
  3. The Dropdown choice is “All” (ddval = 0)

The Template AToggleBit is invisible otherwise. Thus we got the following code:

visibility = stateValue == 0 or \ (stateValue == 1 and ddval != 2) or \ ddval == 0

Then, I also have script in the Dropdown to do the reverse. That is, to choose between the three options: “All”, “Used Only”, and “Active Only” - and to show the AToggleBit Templates according to the choice:

All -> Show all AToggleBit
Used Only -> Show all used or active AToggleBit (stateValue = 0 or stateValue = 1)
Active Only -> Show only active AToggleBit (stateValue = 0)

Now, here is the problem.

Naturally we have the following possibilities in the actual application:

  1. The Dropdown value is changed
  2. The MSI state in the AToggleBit is changed

In either case, I want the AToggleBit visibility to be consistent with the Dropdown value. However…

The script runs well, but only under the following conditions:

  1. The Dropdown value is not changed while the MSI state is changed, or
  2. The Dropdown value is changed but the AToggleBit is still shown when the Dropdown is changed. For example, when the MSI state in the AToggleBit is “OK” (stateValue = 1) and the Dropdown is changed from “All” to “Used only” -> The AToggleBit is still visible. The behavior is consistent

However, once:

  1. the Dropdown value changes, and it changes the AToggleBit’s visibility to False
  2. while the Dropdown value remains, the MSI state in the AToggleBit is changed to something that should be visible under this rule (for instance, stateValue = 0):

[code]visibility = stateValue == 0 or
(stateValue == 1 and ddval != 2) or
ddval == 0

atogglebit.visible = visibility #change the visibility of the template

[/code]

BUT the AToggleBit remains invisible! That is, once is it invisible, no matter what happen to its child component (MSI state changes), it remains invisible still! I check using print in the code to ensure that the child component’s (MSI’s) script is run -> It is run. Furthermore, the visibility value of the script is correct (True). And the component atogglebit is also assigned correctly. THERE IS NO ERROR AT ALL – but it is just the AToggleBit does not become visible although the script shows the assignment very clearly:

atogglebit.visible = visibility #change the visibility of the template

Why is this so?

The strange thing is this: when the Dropdown value is not changed to make the visible AToggleBit invisible, then the script in the AToggleBit’s MSI can run well!

Suppose the Dropdown value remains, then I can see the AToggleBit becomes visible or invisible according to the MSI state changes alone.

But once the Dropdown value changes the AToggleBit from visible to invisible, then no matter what happen to the AToggleBit’s MSI state - although the script is still run - the visibility never changes back to visible.

Why is that so?