# Window Slide on Activation

**URL:** <https://forum.inductiveautomation.com/t/window-slide-on-activation/8420>\
**Category:** Ignition\
**Created:** [May 7, 2014, 3:14pm UTC](https://forum.inductiveautomation.com/t/window-slide-on-activation/8420 "2014-05-07T15:14:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![HushADC](https://avatars.discourse-cdn.com/v4/letter/h/ecb155/32.png) [@HushADC](https://forum.inductiveautomation.com/u/HushADC)\
**Post date:** [May 7, 2014, 3:14pm UTC](https://forum.inductiveautomation.com/t/window-slide-on-activation/8420/1 "2014-05-07T15:14:23Z")

</div>

Hello!

I have been attempting to set up a window such that when I click the button that opens it, the window slides from left to right.

I am hoping to use this as a sub-menu to my tabs on the left side of my screen. I have been able to make the screen move every time I click the button that opens it, but I have not been able to have it slide on its own.

This is my current script in the InternalFrameActivated event handler for the moving window.

x = system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Timer’).value  
y = 0  
window = fpmi.gui.openWindow(‘window folder/window’)  
window.setLocation(x,y)

This script is bound to a timer so that when the timer makes a step, the window position changes. I realize that this should be under a different event handler but I am unsure where to put it or how to make it work correctly.

I am a bit new to scripting in Ignition so any help would be appreciated 🙂

---

<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:** [May 7, 2014, 7:15pm UTC](https://forum.inductiveautomation.com/t/window-slide-on-activation/8420/2 "2014-05-07T19:15:30Z")

</div>

If you create another docked window to the West and open that window, then you should get the affect you are looking for. Try it out.

---

<div class="post-metadata">

**Author:** ![HushADC](https://avatars.discourse-cdn.com/v4/letter/h/ecb155/32.png) [@HushADC](https://forum.inductiveautomation.com/u/HushADC)\
**Post date:** [May 7, 2014, 7:56pm UTC](https://forum.inductiveautomation.com/t/window-slide-on-activation/8420/3 "2014-05-07T19:56:08Z")

</div>

Well I am trying to get the sub-menu to actually slide out from behind my docked window and have it stop right next to it instead of it just appearing there or pushing over another docked window.

I did as you suggested and its not really what I’m looking for, not sure if my first post was as clear as I thought.

I’m actually looking to make the sub-menu window slide sideways, in my case slide 150 east over a period of 1 second.

---

<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:** [May 7, 2014, 8:26pm UTC](https://forum.inductiveautomation.com/t/window-slide-on-activation/8420/4 "2014-05-07T20:26:44Z")

</div>

Try this (make sure your current navigation window has a higher [layer](http://inductiveautomation.com/support/usermanuals/ignition/window_properties.htm) than the new window):

```auto
def doAsych():
	import system
	from time import sleep
	
	sWinName = "submenu" 
	win = system.nav.openWindow(sWinName)
	
	xmax = 150
	win.setLocation(0,0)
	for i in range(xmax):
		sleep(1.0/xmax)
		win.setLocation(i,0)
system.util.invokeAsynchronous(doAsych)
 
```

---

<div class="post-metadata">

**Author:** ![HushADC](https://avatars.discourse-cdn.com/v4/letter/h/ecb155/32.png) [@HushADC](https://forum.inductiveautomation.com/u/HushADC)\
**Post date:** [May 7, 2014, 8:42pm UTC](https://forum.inductiveautomation.com/t/window-slide-on-activation/8420/5 "2014-05-07T20:42:18Z")

</div>

Brilliant!  
Thank you so much ![:prayer:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/e5a7e3b63facc151ea73e3b45db7bdb3d4bdc316.gif ":prayer:")  
I understand most of what you did there, but I wouldn’t mind a bit of explanation for learning purposes 😃

---

<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:** [May 7, 2014, 9:06pm UTC](https://forum.inductiveautomation.com/t/window-slide-on-activation/8420/6 "2014-05-07T21:06:05Z")

</div>

Most of the code inside the function should be self explanatory (open the window and set its location to move it). The only two things that probably need explaining are the sleep function and the doAsych function:

sleep : I used the 1.0 / xmax to have the for loop take 1.0 second of time. You can increase this number (1.5) for a slower slide or decrease it (0.5) for a faster slide. Just make sure to include the decimal, otherwise Python will assume the division result should be an integer and it will simply not sleep.

doAsych : If you don’t use this function, the code will run without updating the view that the user is looking at so the code will go through but it will look just like you simply opened the window. Using Ignition’s [system.util.invokeAsynchronous](http://inductiveautomation.com/support/usermanuals/ignition/system_util_invokeasynchronous.htm), allows the code to run while also updating the screen so the user sees the changes.
