Inconsistent window/component sizing/placement using scripts

I’m encountering some issues with sizing and placement of windows and components using scripting. For example, the following window never resized when it was opened by the user and the bottom part of the popup is “cut off” from the window.

Sometimes all it takes is closing a popup and reopening it for the window and components to size and be positioned correctly (caching is turned off too) which is leaving users and myself confused.

Also, this same popup opened to the correct size the next time it was opened for the same device.

Here is the code used to perform the resize operation too:

	window = system.gui.getWindow("Popups/Gate")
	if (system.gui.getParentWindow(event).getComponentForPath('Root Container').Type==1):
		window.setSize(690,640)
	else:
		window.setSize(690,360)

try calling window.revalidate() after you set it’s size in the script.

Weird. I’m not sure if what I’m seeing right now is because the screens are cached or some other factor, but it looks like the following has seemed to fix our issue.

window.revalidate()
window.doLayout()

Calling window.doLayout() in addition to window.revalidate() seems to have made everything work. I’ll watch this for a few days and see if the issue is actually resolved.

Nevermind. Doesn’t seem to have fixed the issue. Screens still display with bad layouts upon the first time they have been opened then display correctly upon the second open.

Can you reproduce the issue in a short, self-contained example project and send it to us to investigate further?

I have a SSCCE, can I get a ticket for this?

Ok, this was a weird one. Long story short, it was an issue with the script, specifically, how getTagValue works. getTagValue returns the value, or throws a NameError if the tag doesn’t exist, or at least, this is what your script expected. The problem was that getTagValue was sometimes getting a ConfigError, which then returned None as the value, which incremented the “numberVisible” variable but then errored out doing a + operation on None, but that error was swallowed by the except block. So the layout got all messed up because of the numberVisible code.

[del]Here’s some new code to try. It’s full of debug, because it took me ages to tease out the above explanation! Hope this works better for you.[/del]

On second thought, maybe you don’t want the code posted in public. Let us know how you want to proceed.