:right-sidebar: True Cursor =================================================================== .. currentmodule:: gi.repository.Gdk .. class:: Cursor(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` :Constructors: :: Cursor(**properties) new_from_name(name:str, fallback:Gdk.Cursor=None) -> Gdk.Cursor or None new_from_texture(texture:Gdk.Texture, hotspot_x:int, hotspot_y:int, fallback:Gdk.Cursor=None) -> Gdk.Cursor Constructors ------------ .. rst-class:: interim-class .. class:: Cursor :no-index: .. classmethod:: new_from_name(name: str, fallback: ~gi.repository.Gdk.Cursor | None = None) -> ~gi.repository.Gdk.Cursor | 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" | .. image:: https://docs.gtk.org/gdk4/default_cursor.png | .. image:: https://docs.gtk.org/gdk4/help_cursor.png | .. image:: https://docs.gtk.org/gdk4/pointer_cursor.png | | | "default" | "help" | "pointer" | +--------------------------------------------------------------+-----------------------------------------------------------+---------------------------------------------------------------+-------------------------------------------------------------+ | .. image:: https://docs.gtk.org/gdk4/context_menu_cursor.png | .. image:: https://docs.gtk.org/gdk4/progress_cursor.png | .. image:: https://docs.gtk.org/gdk4/wait_cursor.png | .. image:: https://docs.gtk.org/gdk4/cell_cursor.png | | "context-menu" | "progress" | "wait" | "cell" | +--------------------------------------------------------------+-----------------------------------------------------------+---------------------------------------------------------------+-------------------------------------------------------------+ | .. image:: https://docs.gtk.org/gdk4/crosshair_cursor.png | .. image:: https://docs.gtk.org/gdk4/text_cursor.png | .. image:: https://docs.gtk.org/gdk4/vertical_text_cursor.png | .. image:: https://docs.gtk.org/gdk4/alias_cursor.png | | "crosshair" | "text" | "vertical-text" | "alias" | +--------------------------------------------------------------+-----------------------------------------------------------+---------------------------------------------------------------+-------------------------------------------------------------+ | .. image:: https://docs.gtk.org/gdk4/copy_cursor.png | .. image:: https://docs.gtk.org/gdk4/no_drop_cursor.png | .. image:: https://docs.gtk.org/gdk4/move_cursor.png | .. image:: https://docs.gtk.org/gdk4/not_allowed_cursor.png | | "copy" | "no-drop" | "move" | "not-allowed" | +--------------------------------------------------------------+-----------------------------------------------------------+---------------------------------------------------------------+-------------------------------------------------------------+ | .. image:: https://docs.gtk.org/gdk4/grab_cursor.png | .. image:: https://docs.gtk.org/gdk4/grabbing_cursor.png | .. image:: https://docs.gtk.org/gdk4/all_scroll_cursor.png | .. image:: https://docs.gtk.org/gdk4/col_resize_cursor.png | | "grab" | "grabbing" | "all-scroll" | "col-resize" | +--------------------------------------------------------------+-----------------------------------------------------------+---------------------------------------------------------------+-------------------------------------------------------------+ | .. image:: https://docs.gtk.org/gdk4/row_resize_cursor.png | .. image:: https://docs.gtk.org/gdk4/n_resize_cursor.png | .. image:: https://docs.gtk.org/gdk4/e_resize_cursor.png | .. image:: https://docs.gtk.org/gdk4/s_resize_cursor.png | | "row-resize" | "n-resize" | "e-resize" | "s-resize" | +--------------------------------------------------------------+-----------------------------------------------------------+---------------------------------------------------------------+-------------------------------------------------------------+ | .. image:: https://docs.gtk.org/gdk4/w_resize_cursor.png | .. image:: https://docs.gtk.org/gdk4/ne_resize_cursor.png | .. image:: https://docs.gtk.org/gdk4/nw_resize_cursor.png | .. image:: https://docs.gtk.org/gdk4/sw_resize_cursor.png | | "w-resize" | "ne-resize" | "nw-resize" | "sw-resize" | +--------------------------------------------------------------+-----------------------------------------------------------+---------------------------------------------------------------+-------------------------------------------------------------+ | .. image:: https://docs.gtk.org/gdk4/se_resize_cursor.png | .. image:: https://docs.gtk.org/gdk4/ew_resize_cursor.png | .. image:: https://docs.gtk.org/gdk4/ns_resize_cursor.png | .. image:: https://docs.gtk.org/gdk4/nesw_resize_cursor.png | | "se-resize" | "ew-resize" | "ns-resize" | "nesw-resize" | +--------------------------------------------------------------+-----------------------------------------------------------+---------------------------------------------------------------+-------------------------------------------------------------+ | .. image:: https://docs.gtk.org/gdk4/nwse_resize_cursor.png | .. image:: https://docs.gtk.org/gdk4/zoom_in_cursor.png | .. image:: https://docs.gtk.org/gdk4/zoom_out_cursor.png | | | "nwse-resize" | "zoom-in" | "zoom-out" | | +--------------------------------------------------------------+-----------------------------------------------------------+---------------------------------------------------------------+-------------------------------------------------------------+ :param name: the name of the cursor :param fallback: :const:`None` or the ``GdkCursor`` to fall back to when this one cannot be supported .. classmethod:: new_from_texture(texture: ~gi.repository.Gdk.Texture, hotspot_x: int, hotspot_y: int, fallback: ~gi.repository.Gdk.Cursor | None = None) -> ~gi.repository.Gdk.Cursor Creates a new cursor from a ``GdkTexture``. :param texture: the texture providing the pixel data :param hotspot_x: the horizontal offset of the “hotspot” of the cursor :param hotspot_y: the vertical offset of the “hotspot” of the cursor :param fallback: the ``GdkCursor`` to fall back to when this one cannot be supported Methods ------- .. rst-class:: interim-class .. class:: Cursor :no-index: .. method:: get_fallback() -> ~gi.repository.Gdk.Cursor | None Returns the fallback for this ``cursor``. The fallback will be used if this cursor is not available on a given ``GdkDisplay``. For named cursors, this can happen when using nonstandard names or when using an incomplete cursor theme. For textured cursors, this can happen when the texture is too large or when the ``GdkDisplay`` it is used on does not support textured cursors. .. method:: get_hotspot_x() -> int Returns the horizontal offset of the hotspot. The hotspot indicates the pixel that will be directly above the cursor. Note that named cursors may have a nonzero hotspot, but this function will only return the hotspot position for cursors created with :obj:`~gi.repository.Gdk.Cursor.new_from_texture`. .. method:: get_hotspot_y() -> int Returns the vertical offset of the hotspot. The hotspot indicates the pixel that will be directly above the cursor. Note that named cursors may have a nonzero hotspot, but this function will only return the hotspot position for cursors created with :obj:`~gi.repository.Gdk.Cursor.new_from_texture`. .. method:: get_name() -> str | None Returns the name of the cursor. If the cursor is not a named cursor, :const:`None` will be returned. .. method:: get_texture() -> ~gi.repository.Gdk.Texture | None Returns the texture for the cursor. If the cursor is a named cursor, :const:`None` will be returned. Properties ---------- .. rst-class:: interim-class .. class:: Cursor :no-index: .. attribute:: props.fallback :type: ~gi.repository.Gdk.Cursor Cursor to fall back to if this cursor cannot be displayed. .. attribute:: props.hotspot_x :type: int X position of the cursor hotspot in the cursor image. .. attribute:: props.hotspot_y :type: int Y position of the cursor hotspot in the cursor image. .. attribute:: props.name :type: str Name of this this cursor. The name will be :const:`None` if the cursor was created from a texture. .. attribute:: props.texture :type: ~gi.repository.Gdk.Texture The texture displayed by this cursor. The texture will be :const:`None` if the cursor was created from a name.