Label not showing up with script

I have a Label not showing up when my script tells it to. I add to a print statement to the code to see what state it is, and It shows True in the console. I have used the script in the past but it doesn’t seem to work this time.

Yeah, I’ve occasionally had reliable old scripts fail to work in a new situation. Welcome to the club. It’s pretty much always turned out to be my fault, too.

{ This topic is for blowing off steam, right? Otherwise you’d show some code, maybe have a project file as an example, and ask a question, too. }

1 Like

No Steam here. As I said in the console it shows true but doesn’t ever show up. What am I missing. I am sure it is something I have done. But I can’t figure it out.

#imports
import system 
   
#get data from dataset
data = event.source.parent.getComponent('Power Table').data

#get data from dropdown selection
userName = event.source.parent.getComponent('UserName').selectedValue
#get data from dropdown selection
wellwalkerNbr = event.source.parent.getComponent('WWNbr').selectedValue
#validation Error default false
validationError = False
print validationError
print 'ok'
#gets tag value
submitSuccess = True

#validate username
if userName == -1:
	event.source.parent.getComponent('UserName').visible = True
	validationError = True
#validate WWNbr
if wellwalkerNbr == -1:
	event.source.parent.getComponent('WWNbr').visible = True
	validationError = True
#Display error
if validationError:
	event.source.parent.getComponent('ValidationError').visible = True
	print 'here'
	print validationError
	def writeLater():
		event.source.parent.getComponent('ValidationError').visible = False
	system.util.invokeLater(writeLater, 2000)	
	print 'here1'
	print validationError

Still not enough info. What, exactly, shows up in your console? Which component fails to become visible? Does it become visible if you manually toggle it’s visibility property in the designer? Is the component name exactly what you show in your script? Is it grouped or in a container such that it isn’t a sibling of the object generating the event?

Here is the Console results
False
ok
here
True
here1
True
True

It becomes visible if I manually toggle it in the designer. Component Name (ValidationError). It is not apart of a group only the root container.

Where’s the last “True” coming from? Consider making every print statement unique, and include one in writeLater(). Also show the value of the visible property in each print statement. { You can print more than one thing at a time… }

Consider placing your ValidationError component in a temporary variable, too. Makes it much more readable…