Request Help With Gdk.Display

Wildman best_lay at yahoo.com
Wed Aug 16 13:57:16 EDT 2017


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.

-- 
<Wildman> GNU/Linux user #557453
May the Source be with you.



More information about the Python-list mailing list