Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the screen size of two monitors using wx.displaySize()

I want to get the screen size for two monitors using wxPython.

To get the screen size of one monitor: (screenSize is [] containing x and y value).

screenSize = wx.DisplaySize()

but I want something that will work for multiple monitors like the following:

screenSizeMonitor1 = wx.DisplaySize()
screenSizeMonitor2 = wx.DisplaySize()

If possible, it would be nice to know which monitor is on the left (if using two monitors) and which is on the right.

like image 410
Robert Whitley Avatar asked Apr 24 '12 09:04

Robert Whitley


People also ask

How does display size work?

The size of a screen is usually described by the length of its diagonal, which is the distance between opposite corners, usually in inches. It is also sometimes called the physical image size to distinguish it from the "logical image size," which describes a screen's display resolution and is measured in pixels.


1 Answers

You can use the GetGeometry() method of the wx.Display class:

displays = (wx.Display(i) for i in range(wx.Display.GetCount()))
sizes = [display.GetGeometry().GetSize() for display in displays]

To determine the leftmost monitor, you only have to compare the left coordinates of the wx.Rect instances returned by GetGeometry(). The monitor with the smallest left coordinate is the leftmost one.

like image 189
Frédéric Hamidi Avatar answered Sep 21 '22 04:09

Frédéric Hamidi