# How to show Monitor Number using the Label Display?

**URL:** <https://forum.inductiveautomation.com/t/how-to-show-monitor-number-using-the-label-display/93360>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [July 17, 2024, 11:00pm UTC](https://forum.inductiveautomation.com/t/how-to-show-monitor-number-using-the-label-display/93360 "2024-07-17T23:00:37Z")\
**Posts on this page:** 1\
**Showing post:** 6

<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:** [July 19, 2024, 4:44am UTC](https://forum.inductiveautomation.com/t/how-to-show-monitor-number-using-the-label-display/93360/6 "2024-07-19T04:44:40Z")

</div>

> [@simeonw](#):
>
> [system.gui.getScreenIndex | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-gui/system-gui-getScreenIndex)

I suppose it depends on what the screen index is being used for. When I position windows in multi monitor setups, I want the screens to be sequentially indexed from left to right and top to bottom because my windows get covered up, and it makes it easier to find a specific instance in a specific monitor when tabbing. The problem is, screen indexes don't often work that way.

Here's a variation on a script I developed that will return an index based upon which monitor the parent window is in from left to right, top to bottom:

```python
# Import:
# ...GraphicsEnvironment for mapping the screens as they are in reality
# ...JFrame and SwingUtilities for getting the ancestor JFrame of a given component
from java.awt import GraphicsEnvironment
from javax.swing import JFrame, SwingUtilities

def getScreenIndex(component):
	# Get the screen bounds from the graphics environment and sort them from left to right, top to bottom
	screens = sorted([device.defaultConfiguration.bounds for device in GraphicsEnvironment.getLocalGraphicsEnvironment().screenDevices], key=lambda screen: (screen.x, screen.y))
	parentFrame = SwingUtilities.getAncestorOfClass(JFrame, component)
	for index, screen in enumerate(screens):
		if screen.contains(parentFrame.location()):
			return index

# Call the function from any component in any window and do something with the returned screen index
print getScreenIndex(event.source)

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/how-to-show-monitor-number-using-the-label-display/93360)._
