# Change ui from python scripts

**URL:** <https://forum.inductiveautomation.com/t/change-ui-from-python-scripts/41552>\
**Category:** Ignition\
**Created:** [December 16, 2020, 9:43am UTC](https://forum.inductiveautomation.com/t/change-ui-from-python-scripts/41552 "2020-12-16T09:43:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![david4](https://avatars.discourse-cdn.com/v4/letter/d/8e7dd6/32.png) [@david4](https://forum.inductiveautomation.com/u/david4)\
**Post date:** [December 16, 2020, 9:43am UTC](https://forum.inductiveautomation.com/t/change-ui-from-python-scripts/41552/1 "2020-12-16T09:43:19Z")

</div>

Hello everyone!

I am using vision for some graphical interfaces.  
I would like to ask you if anyone knows a way, or, if there is a possibility, of changing the layout of such pages from python scripts.  
In particular, I would like to be able to access the ViewPage source, in order to generate or modify them, automatically, depending on some conditions.

Thanks

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [December 16, 2020, 12:55pm UTC](https://forum.inductiveautomation.com/t/change-ui-from-python-scripts/41552/2 "2020-12-16T12:55:44Z")

</div>

> [@david4](#):
>
> In particular, I would like to be able to access the ViewPage source

That's still pretty vague. What _exactly_ would you like to do? Do you want to move objects around the page? Do you want to add and remove components from the page?  
For the first, you could either use the system.gui.tranform function, or for first and second, you could use the template canvas, assuming your components are templates

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 16, 2020, 1:14pm UTC](https://forum.inductiveautomation.com/t/change-ui-from-python-scripts/41552/3 "2020-12-16T13:14:04Z")

</div>

As Nick notes, you don’t access the XML source. That is an undocumented format and there is no support for manipulating it, nor any jython support for import/export.

Instead you manipulate the components themselves. In the designer, components and their properties are saved in their last state, including any scripted changes.

Vision does **not** formally support runtime addition or removal of components, as it is a bit tricky with undocumented requirements. The supported way to vary the number of components is with the template repeater and/or template canvas.

{Edit: Sorry, missing “not”.}

---

<div class="post-metadata">

**Author:** ![david4](https://avatars.discourse-cdn.com/v4/letter/d/8e7dd6/32.png) [@david4](https://forum.inductiveautomation.com/u/david4)\
**Post date:** [December 16, 2020, 1:36pm UTC](https://forum.inductiveautomation.com/t/change-ui-from-python-scripts/41552/4 "2020-12-16T13:36:53Z")

</div>

Yes, I’m talking about something like an xml file that represents the graphical interface.  
A bit like accessing the DOM in javascript, or an xml resource on android.

But will these files be allocated somewhere?  
Ideally from jython i could access to read and modify them.

The problem is that through the gui.transform(), the page must be opened, or am i wrong? Otherwise i can’t get the page reference, is that correct?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 16, 2020, 1:39pm UTC](https://forum.inductiveautomation.com/t/change-ui-from-python-scripts/41552/5 "2020-12-16T13:39:57Z")

</div>

They are compressed binary resources in an opaque disk format. You cannot edit them without opening them in the designer. Sorry. The XML is only for import and export, and only in the designer.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [December 16, 2020, 8:12pm UTC](https://forum.inductiveautomation.com/t/change-ui-from-python-scripts/41552/6 "2020-12-16T20:12:56Z")

</div>

What Phil said. Perspective on the other hand is a different beast and _does_ support what you’re trying to do. You can manipulate the json file that defines the Views which can add/remove/modify component config permanently. You’re out of luck for Vision though
