(Windows 8, Version 7.8.4)
I’m having an odd bug with the system.gui.reshapeComponent call.
I have two containers (A and B) that are being positioned using reshapeComponent based on their parent container’s © dimensions. The components are re-positioned correctly unless you resize C indirectly . For example, if C has layout anchors on all four sides, resizing C’s parent component will indirectly resize C. In my case, C’s parent is the Root Container.
When the reshapeComponent function is called with an indirectly-resized C, A and B are positioned with weird offsets every time. Sizes seem to be correct, it’s the locations that are incorrect.
These weird offsets can be corrected by going back to edit mode and manually moving ANY component (via either arrow keys or dragging it) in any direction. Suddenly everything will snap to the proper position. After that the reshapeComponent function calls will work as expected until C is indirectly resized again.
The last part is only testable in the designer because you cannot manually re-position elements in published versions, but the positioning errors that occur when resizing the root container in the designer are the same as resizing the window in a published version.
I have tried calling the java functions to revalidate and/or repaint the components
I have included a SSCCE with the code I’m using contained in a custom function inside the “Doc Split Container” component, called from the “Multi-State Button” component.
Here is the code for the custom function in side the “Doc Split Container” component:
[code]def reshapeComponents(self, vertical):
doc1 = self.getComponent(“Doc 1 Container”)
doc2 = self.getComponent(“Doc 2 Container”)
size = self.getSize()
#Resize Doc 1/2 Container depending on whether layout is Vertical or Horizontal #ERROR: Components always seem to end up the proper SIZE but not always at the correct LOCATION if not vertical: #Horizontal system.gui.reshapeComponent(doc1,0,0,size.width/2-5,size.height) system.gui.reshapeComponent(doc2,size.width/2+5,0,size.width/2-5,size.height) else: #Vertical system.gui.reshapeComponent(doc1,0,0,size.width,size.height/2) system.gui.reshapeComponent(doc2,0,size.height/2,size.width,size.height/2) def reshapeDocs(dc): #Resize/position the components within Doc 1/2 Container label = dc.getComponent("Path Label") doc = dc.getComponent("Document Viewer") size2 = dc.getSize() system.gui.reshapeComponent(label,0,0,size2.width,size2.height/10) system.gui.reshapeComponent(doc,0,size2.height/10,size2.width,size2.height*9/10) #Invoke the reshapeDocs calls later to ensure the sizes of the parent # components have properly updated in the UI thread def later(): reshapeDocs(doc1) reshapeDocs(doc2) system.util.invokeLater(later)[/code]
Is this a bug with Ignition or is there a workaround that I can put into my script?