Request Help With Gdk.Display
Wildman
best_lay at yahoo.com
Wed Aug 16 18:13:41 EDT 2017
On Wed, 16 Aug 2017 14:33:27 -0500, Wildman wrote:
> On Wed, 16 Aug 2017 19:11:16 +0100, MRAB wrote:
>
>> On 2017-08-16 18:57, Wildman via Python-list wrote:
>>> I am working on a program for the Linux platform that
>>> reports system information. The program reports screen
>>> information, number of monitors, resolution of each one
>>> and the total resolution. It does it using a couple of
>>> external utils, Xrandr and Xdpyinfo. It is my goal to
>>> replace the existing code with a python solution without
>>> depending on the external programs.
>>>
>>> With the help of a code snippet I found, I came up with
>>> this but it only reports the resolution of the primary
>>> monitor...
>>>
>>> #! /usr/bin/env python3
>>>
>>> import gi
>>> gi.require_version('Gdk', '3.0')
>>> from gi.repository import Gdk
>>>
>>> display = Gdk.Display.get_default()
>>> pm = display.get_primary_monitor()
>>> geo = pm.get_geometry()
>>> w = geo.width
>>> h = geo.height
>>> print(w,h)
>>>
>>>
>>> I know that the number of monitors can be obtained by
>>> using...
>>>
>>> mc = Gdk.Display.get_n_monitors(display)
>>>
>>> Then to get each monitor, this can be used...
>>>
>>> monitor = Gdk.Display.get_monitor(display, monitor_num)
>>>
>>> My problem is that I can't find any information on how
>>> "monitor_num" is obtained. The only thing I have been
>>> able to find out is that it is an integer. Can anybody
>>> point me in the right direction? Much appreciated.
>>>
>> If get_n_monitors tells you how many monitors there are, isn't
>> monitor_num just an index (0, 1, 2, ...)?
>
> I don't know. The documentation doesn't say. That is
> something I can test that I hadn't thought of. I hope
> you are right. It would be nice if it was that simple.
> Thanks.
In case anyone is interested that was the answer.
Thanks again MRAB.
--
<Wildman> GNU/Linux user #557453
The cow died so I don't need your bull!
More information about the Python-list
mailing list