8
votes

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.

1

1 Answers

15
votes

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.