Skip to content

Gdk.Monitor

class — extends GObject.Object

Represents the individual outputs that are associated with a GdkDisplay.

GdkDisplay keeps a GListModel to enumerate and monitor monitors with Display.get_monitors. You can use Display.get_monitor_at_surface to find a particular monitor.

Methods

get_connector

def get_connector(self) -> str | None

Gets the name of the monitor's connector, if available.

These are strings such as "eDP-1", or "HDMI-2". They depend on software and hardware configuration, and should not be relied on as stable identifiers of a specific monitor.

get_description

def get_description(self) -> str | None

Gets a string describing the monitor, if available.

This can be used to identify a monitor in the UI.

get_display

def get_display(self) -> Display

Gets the display that this monitor belongs to.

get_geometry

def get_geometry(self) -> Rectangle

Retrieves the size and position of the monitor within the display coordinate space.

The returned geometry is in ”application pixels”, not in ”device pixels” (see Monitor.get_scale).

get_height_mm

def get_height_mm(self) -> int

Gets the height in millimeters of the monitor.

get_manufacturer

def get_manufacturer(self) -> str | None

Gets the name or PNP ID of the monitor's manufacturer.

Note that this value might also vary depending on actual display backend.

The PNP ID registry is located at https://uefi.org/pnp_id_list.

get_model

def get_model(self) -> str | None

Gets the string identifying the monitor model, if available.

get_refresh_rate

def get_refresh_rate(self) -> int

Gets the refresh rate of the monitor, if available.

The value is in milli-Hertz, so a refresh rate of 60Hz is returned as 60000.

get_scale

def get_scale(self) -> float

Gets the internal scale factor that maps from monitor coordinates to device pixels.

This can be used if you want to create pixel based data for a particular monitor, but most of the time you’re drawing to a surface where it is better to use Surface.get_scale instead.

get_scale_factor

def get_scale_factor(self) -> int

Gets the internal scale factor that maps from monitor coordinates to device pixels.

On traditional systems this is 1, but on very high density outputs it can be a higher value (often 2).

This can be used if you want to create pixel based data for a particular monitor, but most of the time you’re drawing to a surface where it is better to use Surface.get_scale_factor instead.

get_subpixel_layout

def get_subpixel_layout(self) -> SubpixelLayout

Gets information about the layout of red, green and blue primaries for pixels.

get_width_mm

def get_width_mm(self) -> int

Gets the width in millimeters of the monitor.

is_valid

def is_valid(self) -> bool

Returns True if the monitor object corresponds to a physical monitor.

The monitor becomes invalid when the physical monitor is unplugged or removed.

Properties

connector

connector: str  # read-only

The connector name.

description

description: str  # read-only

A short description of the monitor, meant for display to the user.

display

display: Display  # read/write

The GdkDisplay of the monitor.

geometry

geometry: Rectangle  # read-only

The geometry of the monitor.

height_mm

height_mm: int  # read-only

The height of the monitor, in millimeters.

manufacturer

manufacturer: str  # read-only

The manufacturer name.

model

model: str  # read-only

The model name.

refresh_rate

refresh_rate: int  # read-only

The refresh rate, in milli-Hertz.

scale

scale: float  # read-only

The scale of the monitor.

scale_factor

scale_factor: int  # read-only

The scale factor.

The scale factor is the next larger integer, compared to Surface.scale.

subpixel_layout

subpixel_layout: SubpixelLayout | int  # read-only

The subpixel layout.

valid

valid: bool  # read-only

Whether the object is still valid.

width_mm

width_mm: int  # read-only

The width of the monitor, in millimeters.

Signals

invalidate

def on_invalidate(self) -> None: ...

Emitted when the output represented by monitor gets disconnected.