Robert Whitley
Robert Whitley

Reputation: 1081

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.

Upvotes: 8

Views: 7406

Answers (1)

Frédéric Hamidi
Frédéric Hamidi

Reputation: 262949

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.

Upvotes: 16

Related Questions