# Popup window and Window size and location problem

**URL:** <https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243>\
**Category:** Ignition\
**Tags:** vision, ignition81\
**Created:** [November 22, 2023, 10:07am UTC](https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243 "2023-11-22T10:07:03Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [November 22, 2023, 10:07am UTC](https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243/1 "2023-11-22T10:07:03Z")

</div>

Hello,

I was trying to make a popup window and place it on a specific location in one of my main windows, but it looks like the whole location thing does not work or I don't understand how it works.  
Let me explain my problem:

I have a window with the following position and size:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/1/81aac62925ce79c49e881ec16b9955b373bb00c5.png)  
If I want a popup window to be on the right side of the main window and the size of the popup window is: 255/1190. I have to subtract 255 from 2520 right? then it should be exactly on the right side of my main window. but instead, it ends up further away.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/b/8bcf1af0a16913896be83758e47ce2b041179336.png)

And besides that, the whole screen gets zoomed and that is not what I want.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [November 22, 2023, 10:29am UTC](https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243/2 "2023-11-22T10:29:55Z")

</div>

How is your popup being triggered? ...from a button?

What does your code look like?

Here are a few examples of popup position manipulation that seem relevant to your question:  
• [Open popup at bottom right corner of the window](https://forum.inductiveautomation.com/t/open-popup-at-bottom-right-corner-of-the-window/71477/8)

• [Popup Windows Debugging](https://forum.inductiveautomation.com/t/popup-windows-debugging/66679)

• [Resize Popup Window but not Content in Window](https://forum.inductiveautomation.com/t/resize-popup-window-but-not-content-in-window/74387)

---

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [November 22, 2023, 10:33am UTC](https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243/3 "2023-11-22T10:33:52Z")

</div>

I open it with a button. and the button is configured as follows

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/7/27efbb69e13f017430a18041cd56abedd0e15648.png)  
There is no code.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [November 22, 2023, 10:40am UTC](https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243/4 "2023-11-22T10:40:09Z")

</div>

• Change the action in the Navigation tab to "No Action."  
• Then, click on the "Script Editor" tab, and open the popup with a script.

```auto
# Get the parent window
parentWindow = system.gui.getParentWindow(event)

# Get and open the popup
popup = system.nav.openWindow('CM/Popup')

# Calculate the desired coordinates for the popup's position
x = parentWindow.width - popup.width # Far right of Main Window
y = 0 # Top of Main Window

# Position the popup
popup.setLocation(x, y)

```

---

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [November 22, 2023, 11:01am UTC](https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243/5 "2023-11-22T11:01:22Z")

</div>

> [@justinedwards.jle](#):
>
> ```auto
> # Get the parent window
> parentWindow = system.gui.getParentWindow(event)
> 
> # Get and open the popup
> popup = system.nav.openWindow('CM/Popup')
> 
> # Calculate the desired coordinates for the popup's position
> x = parentWindow.width - popup.width # Far right of Main Window
> y = 0 # Top of Main Window
> 
> # Position the popup
> popup.setLocation(x, y)
> 
> ```

It still does the same thing. Not as I want. I have lowered the Y a bit so you can see that the popup is still not aligned with my main window.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/a/bac9e3ecd171c2e18081411add1e5f488596c54a.png)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [November 22, 2023, 11:06am UTC](https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243/6 "2023-11-22T11:06:20Z")

</div>

What is that header component with a blue background that is displaying the time? Is that a docked window, a container of some kind, a label? Perhaps we can simply position off of that.

---

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [November 22, 2023, 11:06am UTC](https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243/7 "2023-11-22T11:06:37Z")

</div>

Main window

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/8/981e24c45674e47ed4ac5308d18c1fce71d6b058.png)  
The popup window should get over the rootcontainer on the right side of the main window

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [November 22, 2023, 11:16am UTC](https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243/8 "2023-11-22T11:16:09Z")

</div>

I'm guessing from the tab strip we've got some docked windows going on that are offsetting the coordinates. Are there docked windows?

What prints in the console if you add this to your code?

```auto
print parentWindow.path

```

Does the button retrieve the main window as its parent?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [November 22, 2023, 11:20am UTC](https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243/9 "2023-11-22T11:20:53Z")

</div>

I think you need something to reference where the parent window is on the screen.

```python
x = parentWindow.getLocationOnScreen().x + parentWindow.width - popup.width

```

---

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [November 22, 2023, 11:21am UTC](https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243/10 "2023-11-22T11:21:53Z")

</div>

yes there are docked windows I use that pop next to this window I just added in a reply. For the `print parentWindow.path` should I replace 'Window' for the name of my main window?

---

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [November 22, 2023, 11:24am UTC](https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243/11 "2023-11-22T11:24:18Z")

</div>

> [@JordanCClark](#):
>
> `x = parentWindow.getLocationOnScreen().x + parentWindow.width - popup.width`

This didn't change anything.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [November 22, 2023, 11:24am UTC](https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243/12 "2023-11-22T11:24:45Z")

</div>

> [@Stef\_Velers](#):
>
> should I replace 'Window' for the name of my main window

This:

```auto
parentWindow = system.gui.getParentWindow(event)
print parentWindow.path

```

---

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [November 22, 2023, 11:25am UTC](https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243/13 "2023-11-22T11:25:24Z")

</div>

Sorry im not sure what parentWindow does? because nothing is printing in the console

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [November 22, 2023, 11:28am UTC](https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243/14 "2023-11-22T11:28:04Z")

</div>

Click Tools--\>Console

Click this button to clear any preexisting stuff:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/6/c6111495885cfbadef42ac0c1298f39acc69feac.png)

Then, run this code from the button's actionPerformed event handler:

```auto
parentWindow = system.gui.getParentWindow(event)
print 'Parent Window Path: ', parentWindow.path

```

See what prints out

---

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [November 22, 2023, 11:32am UTC](https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243/15 "2023-11-22T11:32:24Z")

</div>

> [@justinedwards.jle](#):
>
> ```auto
> parentWindow = system.gui.getParentWindow(event)
> print 'Parent Window Path: ', parentWindow.path
> 
> ```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/0/e095b6e8e9f54cd8ecb4978ae4fe826d0ac708db.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/8/5810cf9e8785a5a069c591f3c006cc84b04e1b8e.png)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [November 22, 2023, 11:37am UTC](https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243/16 "2023-11-22T11:37:43Z")

</div>

Line 8? There should only be two lines.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [November 22, 2023, 11:40am UTC](https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243/17 "2023-11-22T11:40:03Z")

</div>

Is that a docked area on the right hand side, and is it where the button resides?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [November 22, 2023, 11:44am UTC](https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243/18 "2023-11-22T11:44:35Z")

</div>

I'm also imagining that the button is not in the main window, and we are going to have figure out the relative position to get the coordinate right.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [November 22, 2023, 11:47am UTC](https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243/19 "2023-11-22T11:47:54Z")

</div>

You just need to reference the window name.

```python
mainWindow = system.gui.getWindow('Window Name')
x = mainWindow.getLocationOnScreen().x + mainWindow.width - popup.width
y = mainWindow.getLocationOnScreen().y

popup.setLocation(x, y)

```

---

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [November 22, 2023, 12:10pm UTC](https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243/20 "2023-11-22T12:10:12Z")

</div>

with the code you send is this what i get:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/e/0e684e644ad3650d7e4e3a932a173f00746abd77.png)  
Stil not on the right place. Also every time I click the button so that it opens the popup window everything gets zoomed in for some reason.

[Next page](https://forum.inductiveautomation.com/t/popup-window-and-window-size-and-location-problem/82243.md?page=2)
