Accessing previous window's position


I am working on a navigation bar at the moment in Ignition (it is not the built in script navbar). I am trying to get the windows once they are opened to be left aligned with the button that opens them (Just like every normal navigation bar). I am using a docked window at the North of the screen to be the navigation bar and all the windows are operating - I just need to somehow pass the x-values of the buttons on the docked navigation bar to the location of the opened windows.

Thank you in advance.

You can try this:

sWindowToOpen = "popup" 

newWindow = system.nav.openWindow(sWindowToOpen)

If you have no docked windows to the west, this should work just fine. (NOTE: using getX() and getY() here are undocumented and may be removed in future releases of Ignition.)

That worked like a charm! Thank you!

What does getX() return for a value? I was trying to offset another menu 128 pixels to the right - I thought it would just be an int but after printing and testing it, that doesn’t seem to be the case.

I tried to just do event.source.getX() + 128 (Thinking it was just an int) and I got my menu at 128 pixels.

event.source is whichever component you are in when the code is executing. So maybe you could try thinking about it differently if you are in a different button. This code seems to work for me:

sWindowToOpen = "popup" 

newWindow = system.nav.openWindow(sWindowToOpen)
newWindow.setLocation(event.source.getX() + 128,newWindow.getY())

I know what the issue is - I am just at a loss of how to fix it. This is my first experience with any SCADA program and Ignition. I only have a familiarity with Python GUI/Window commands.

What I am doing is getting a window to open from a task bar and then that window has another window opening from it, left alighted with the right side of the first menu if that makes sense.

What I need is to replace the event.source.getX() (of the second menu) with filemenu.button 1.getX() but I do not know how python organizes it. I have to do this because I checked and when you use the .getX() of a window to position the first window - the value isn’t stored in the the menu…it thinks its at 0,0 for some reason. So when I go to do event.source.getX() + 128. It is doing the addition but it thinks the value is only 128.

Really I guess I just need a reference, but I am not really sure what I am supposed to be searching for.

Any help would be appreciated!

EDIT: I believe that I should be using .getWindow(Nav_bar) in order to open it - then I should be able to do .rootContainer…Button 3.getX() but I get an error for .getWindow even though it is open.

Try system.gui.getParentWindow:

thisWindow = system.gui.getParentWindow(event)
root = thisWindow.rootContainer

Then try root.getComponent(“button 1”) and keep trying!

Aright well I finally got it to stick correctly with this - I am not sure how much of a hackjob it is

I appreciate all the help. I gotta get this reference system down!

sWindowToOpen = ‘Navigation/System/Navigation_System_Communications’
window = system.gui.getWindow(“Navigation/Navigation_Bar”)
position = window.rootContainer.getComponent(“Button 1”)
newWindow = system.nav.openWindow(sWindowToOpen)


except ValueError: