Vision Application Screen Indexing Issue

I work with a lot of multi screen systems as well, and I like the the desktop names to be numbered from left to right and top to bottom as seen below

Here is the code I developed for sorting the screens:

from java.awt import GraphicsEnvironment

# Get the bounds of each screen from the graphics environment and sort them from right to left, top to bottom
screens = sorted([device.defaultConfiguration.bounds for device in GraphicsEnvironment.getLocalGraphicsEnvironment().screenDevices], key=lambda screen: (screen.x, screen.y))
for index, screen in enumerate(screens):
	
	# Find the desired screen and do something with it here
	# The indexes will be sorted from left to right and top to bottom
	print index, screen.x, screen.y, screen.width, screen.height

Here are some forum examples where I've demonstrated this approach:
Dual Monitor Screen Number Issue
How to Show Monitor Number Using the Label Display

2 Likes