Gdk.Cursor

g GObject.Object GObject.Object Gdk.Cursor Gdk.Cursor GObject.Object->Gdk.Cursor

Subclasses:None

Methods

Inherited:GObject.Object (37)
Structs:GObject.ObjectClass (5)
class new (cursor_type)
class new_for_display (display, cursor_type)
class new_from_name (display, name)
class new_from_pixbuf (display, pixbuf, x, y)
class new_from_surface (display, surface, x, y)
  get_cursor_type ()
  get_display ()
  get_image ()
  get_surface ()
  ref ()
  unref ()

Virtual Methods

Inherited:GObject.Object (7)

Properties

Name Type Flags Short Description
cursor-type Gdk.CursorType r/w/co Standard cursor type
display Gdk.Display r/w/co Display of this cursor

Signals

Inherited:GObject.Object (1)

Fields

Inherited:GObject.Object (1)

Class Details

class Gdk.Cursor(**kwargs)
Bases:GObject.Object
Abstract:Yes

A Gdk.Cursor represents a cursor. Its contents are private.

classmethod new(cursor_type)[source]
Parameters:cursor_type (Gdk.CursorType) – cursor to create
Returns:a new Gdk.Cursor
Return type:Gdk.Cursor

Creates a new cursor from the set of builtin cursors for the default display. See Gdk.Cursor.new_for_display().

To make the cursor invisible, use Gdk.CursorType.BLANK_CURSOR.

Deprecated since version 3.16: Use Gdk.Cursor.new_for_display() instead.

classmethod new_for_display(display, cursor_type)[source]
Parameters:
Returns:

a new Gdk.Cursor

Return type:

Gdk.Cursor

Creates a new cursor from the set of builtin cursors.

New in version 2.2.

classmethod new_from_name(display, name)[source]
Parameters:
Returns:

a new Gdk.Cursor, or None if there is no cursor with the given name

Return type:

Gdk.Cursor or None

Creates a new cursor by looking up name in the current cursor theme.

A recommended set of cursor names that will work across different platforms can be found in the CSS specification:

  • “none”
  • “default”
  • “help”
  • “pointer”
  • “context-menu”
  • “progress”
  • “wait”
  • “cell”
  • “crosshair”
  • “text”
  • “vertical-text”
  • “alias”
  • “copy”
  • “no-drop”
  • “move”
  • “not-allowed”
  • “grab”
  • “grabbing”
  • “all-scroll”
  • “col-resize”
  • “row-resize”
  • “n-resize”
  • “e-resize”
  • “s-resize”
  • “w-resize”
  • “ne-resize”
  • “nw-resize”
  • “sw-resize”
  • “se-resize”
  • “ew-resize”
  • “ns-resize”
  • “nesw-resize”
  • “nwse-resize”
  • “zoom-in”
  • “zoom-out”

New in version 2.8.

classmethod new_from_pixbuf(display, pixbuf, x, y)[source]
Parameters:
Returns:

a new Gdk.Cursor.

Return type:

Gdk.Cursor

Creates a new cursor from a pixbuf.

Not all GDK backends support RGBA cursors. If they are not supported, a monochrome approximation will be displayed. The functions Gdk.Display.supports_cursor_alpha() and Gdk.Display.supports_cursor_color() can be used to determine whether RGBA cursors are supported; Gdk.Display.get_default_cursor_size() and Gdk.Display.get_maximal_cursor_size() give information about cursor sizes.

If x or y are -1, the pixbuf must have options named “x_hot” and “y_hot”, resp., containing integer values between 0 and the width resp. height of the pixbuf. (Since: 3.0)

On the X backend, support for RGBA cursors requires a sufficently new version of the X Render extension.

New in version 2.4.

classmethod new_from_surface(display, surface, x, y)[source]
Parameters:
  • display (Gdk.Display) – the Gdk.Display for which the cursor will be created
  • surface (cairo.Surface) – the cairo image surface containing the cursor pixel data
  • x (float) – the horizontal offset of the “hotspot” of the cursor
  • y (float) – the vertical offset of the “hotspot” of the cursor
Returns:

a new Gdk.Cursor.

Return type:

Gdk.Cursor

Creates a new cursor from a cairo image surface.

Not all GDK backends support RGBA cursors. If they are not supported, a monochrome approximation will be displayed. The functions Gdk.Display.supports_cursor_alpha() and Gdk.Display.supports_cursor_color() can be used to determine whether RGBA cursors are supported; Gdk.Display.get_default_cursor_size() and Gdk.Display.get_maximal_cursor_size() give information about cursor sizes.

On the X backend, support for RGBA cursors requires a sufficently new version of the X Render extension.

New in version 3.10.

get_cursor_type()[source]
Returns:a Gdk.CursorType
Return type:Gdk.CursorType

Returns the cursor type for this cursor.

New in version 2.22.

get_display()[source]
Returns:the Gdk.Display associated to self
Return type:Gdk.Display

Returns the display on which the Gdk.Cursor is defined.

New in version 2.2.

get_image()[source]
Returns:a GdkPixbuf.Pixbuf representing self, or None
Return type:GdkPixbuf.Pixbuf or None

Returns a GdkPixbuf.Pixbuf with the image used to display the cursor.

Note that depending on the capabilities of the windowing system and on the cursor, GDK may not be able to obtain the image data. In this case, None is returned.

New in version 2.8.

get_surface()[source]
Returns:a cairo.Surface representing self, or None
x_hot:Location to store the hotspot x position, or None
y_hot:Location to store the hotspot y position, or None
Return type:(cairo.Surface or None, x_hot: float, y_hot: float)

Returns a cairo image surface with the image used to display the cursor.

Note that depending on the capabilities of the windowing system and on the cursor, GDK may not be able to obtain the image data. In this case, None is returned.

New in version 3.10.

ref()[source]
Returns:Same self that was passed in
Return type:Gdk.Cursor

Adds a reference to self.

Deprecated since version 3.0: Use GObject.Object.ref() instead

unref()[source]

Removes a reference from self, deallocating the cursor if no references remain.

Deprecated since version 3.0: Use GObject.Object.unref() instead

Property Details

Gdk.Cursor.props.cursor_type
Name:cursor-type
Type:Gdk.CursorType
Default Value:Gdk.CursorType.X_CURSOR
Flags:READABLE, WRITABLE, CONSTRUCT_ONLY

Standard cursor type

Gdk.Cursor.props.display
Name:display
Type:Gdk.Display
Default Value:None
Flags:READABLE, WRITABLE, CONSTRUCT_ONLY

Display of this cursor