Converting Number to String and Assigning to Component in Script Console Bug

I am doing something very simple. I am trying to assign a number to a text field component in the script console. When I try to convert to a string and then assign, the script console freezes along with the designer. Assigning a string works correctly.

Is this a bug? Can anyone reproduce the problem?

UPDATE:
Just tried with a numeric text field and encountered the same problem, assigning a number without conversion to string.

Does it work if you do the assignment inside something you used system.util.invokeLater on?

Yes, doing the following works without issue.
NOTE: changed text field name to output

import random

def do_it():
	w=system.gui.getWindow('Main Window')
	c=w.rootContainer.getComponent('output')
	c.text = str( random.randint(0,100) )
	
#do_it()
system.util.invokeLater(do_it)

Alright, well… there’s a bug, but it’s in your script :wink:

The script console executes code in a worker thread, not on the UI thread, which makes any manipulation of the UI off limits unless you throw it into an invokeLater so it gets run on the UI thread.

1 Like