# Accessing previous window's position

**URL:** <https://forum.inductiveautomation.com/t/accessing-previous-windows-position/8595>\
**Category:** Ignition\
**Created:** [June 20, 2014, 12:36pm UTC](https://forum.inductiveautomation.com/t/accessing-previous-windows-position/8595 "2014-06-20T12:36:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![c\_hurd](https://avatars.discourse-cdn.com/v4/letter/c/82dd89/32.png) [@c\_hurd](https://forum.inductiveautomation.com/u/c_hurd)\
**Post date:** [June 20, 2014, 12:36pm UTC](https://forum.inductiveautomation.com/t/accessing-previous-windows-position/8595/1 "2014-06-20T12:36:48Z")

</div>

Howdy,

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.

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [June 20, 2014, 3:51pm UTC](https://forum.inductiveautomation.com/t/accessing-previous-windows-position/8595/2 "2014-06-20T15:51:18Z")

</div>

You can try this:

```auto
sWindowToOpen = "popup" 

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

```

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.)

---

<div class="post-metadata">

**Author:** ![c\_hurd](https://avatars.discourse-cdn.com/v4/letter/c/82dd89/32.png) [@c\_hurd](https://forum.inductiveautomation.com/u/c_hurd)\
**Post date:** [June 20, 2014, 4:49pm UTC](https://forum.inductiveautomation.com/t/accessing-previous-windows-position/8595/3 "2014-06-20T16:49:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [June 20, 2014, 5:34pm UTC](https://forum.inductiveautomation.com/t/accessing-previous-windows-position/8595/4 "2014-06-20T17:34:16Z")

</div>

[event.source](http://inductiveautomation.com/support/usermanuals/ignition/the_event_object.htm) 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:

```auto

sWindowToOpen = "popup" 

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

```

---

<div class="post-metadata">

**Author:** ![c\_hurd](https://avatars.discourse-cdn.com/v4/letter/c/82dd89/32.png) [@c\_hurd](https://forum.inductiveautomation.com/u/c_hurd)\
**Post date:** [June 20, 2014, 6:00pm UTC](https://forum.inductiveautomation.com/t/accessing-previous-windows-position/8595/5 "2014-06-20T18:00:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [June 20, 2014, 6:23pm UTC](https://forum.inductiveautomation.com/t/accessing-previous-windows-position/8595/6 "2014-06-20T18:23:59Z")

</div>

Try [system.gui.getParentWindow](http://inductiveautomation.com/support/usermanuals/ignition/system_gui_getparentwindow.htm):

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

Then try [root.getComponent(“button 1”)](http://inductiveautomation.com/support/usermanuals/ignition/the_event_object.htm) and keep trying!

---

<div class="post-metadata">

**Author:** ![c\_hurd](https://avatars.discourse-cdn.com/v4/letter/c/82dd89/32.png) [@c\_hurd](https://forum.inductiveautomation.com/u/c_hurd)\
**Post date:** [June 20, 2014, 6:28pm UTC](https://forum.inductiveautomation.com/t/accessing-previous-windows-position/8595/7 "2014-06-20T18:28:23Z")

</div>

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!

[code]  
try:  
sWindowToOpen = ‘Navigation/System/Navigation\_System\_Communications’  
window = system.gui.getWindow(“Navigation/Navigation\_Bar”)  
position = window.rootContainer.getComponent(“Button 1”)  
newWindow = system.nav.openWindow(sWindowToOpen)  
newWindow.setLocation(position.getX()+136,event.source.getY())

```
system.nav.closeWindow('Navigation/System/Navigation_System_Snapshot')

```

except ValueError:  
pass[/code]
