# swapTo window swapping

**URL:** <https://forum.inductiveautomation.com/t/swapto-window-swapping/91024>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [May 28, 2024, 5:45pm UTC](https://forum.inductiveautomation.com/t/swapto-window-swapping/91024 "2024-05-28T17:45:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![leversole](https://avatars.discourse-cdn.com/v4/letter/l/db5fbb/32.png) [@leversole](https://forum.inductiveautomation.com/u/leversole)\
**Post date:** [May 28, 2024, 5:45pm UTC](https://forum.inductiveautomation.com/t/swapto-window-swapping/91024/1 "2024-05-28T17:45:06Z")

</div>

Trying to get a window to swap based on a list box choice...I am passing (according to a console print) the exact string to swap the window...error message is a window by that name cannot be found...like I said, it is returning the full path to the window....'NAV/TopWindow' eg...(with single quotes)  
If I copy the exact text from the console, and paste it into the swapTo, it opens the window.  
the code runs on the mouse clicked action of the list box...

```python
 #get the value from the list box
 winSelect=event.source.getSelectedValue()
 
 #run the query to get the window path
 pathData=system.db.runPrepQuery("SELECT WindowPath FROM JobMenu WHERE MenuItem=?", [winSelect])
 
 #write value so we can swap out the window
 winPath = "'" + pathData.getValueAt(0, 0) + "'"
 
 #swap the window we selected
 system.nav.swapTo(winPath)

```

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 28, 2024, 5:50pm UTC](https://forum.inductiveautomation.com/t/swapto-window-swapping/91024/2 "2024-05-28T17:50:34Z")

</div>

You've posted code as a quotation. You need to format it as code. Please see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831) and use the pencil icon button to edit your post. It's especially important to reveal Python indentation (or none). Thanks.

---

<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:** [May 29, 2024, 1:20am UTC](https://forum.inductiveautomation.com/t/swapto-window-swapping/91024/3 "2024-05-29T01:20:27Z")

</div>

> [@leversole](#):
>
> `"'"`

There is no need to add apostrophes to the string that is being returned by `pathData.getValueAt(0, 0)`. Instead, simply hand the string to the `swapTo` method directly without modification:

```python
 winPath = pathData.getValueAt(0, 0)
 
 system.nav.swapTo(winPath)

```

or

```python
system.nav.swapTo(pathData.getValueAt(0, 0))

```

---

<div class="post-metadata">

**Author:** ![leversole](https://avatars.discourse-cdn.com/v4/letter/l/db5fbb/32.png) [@leversole](https://forum.inductiveautomation.com/u/leversole)\
**Post date:** [May 29, 2024, 2:49am UTC](https://forum.inductiveautomation.com/t/swapto-window-swapping/91024/4 "2024-05-29T02:49:29Z")

</div>

Thanks, I had already tried without the quotes...but tried again to make sure...  
I looked for the 50th time and realized I had all caps for the folder name the window was in! Typos killing me!  
Thanks for the assist!
