:right-sidebar: True ColorDialog =================================================================== .. currentmodule:: gi.repository.Gtk .. versionadded:: 4.10 .. class:: ColorDialog(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` A ``GtkColorDialog`` object collects the arguments that are needed to present a color chooser dialog to the user, such as a title for the dialog and whether it should be modal. The dialog is shown with the :obj:`~gi.repository.Gtk.ColorDialog.choose_rgba` function. This API follows the GIO async pattern, and the result can be obtained by calling :obj:`~gi.repository.Gtk.ColorDialog.choose_rgba_finish`. See :obj:`~gi.repository.Gtk.ColorDialogButton` for a convenient control that uses ``GtkColorDialog`` and presents the results. Constructors ------------ .. rst-class:: interim-class .. class:: ColorDialog :no-index: .. classmethod:: new() -> ~gi.repository.Gtk.ColorDialog Creates a new ``GtkColorDialog`` object. .. versionadded:: 4.10 Methods ------- .. rst-class:: interim-class .. class:: ColorDialog :no-index: .. method:: choose_rgba(parent: ~gi.repository.Gtk.Window | None = None, initial_color: ~gi.repository.Gdk.RGBA | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[...], None] | None = None, *user_data: ~typing.Any) -> None This function initiates a color choice operation by presenting a color chooser dialog to the user. The ``callback`` will be called when the dialog is dismissed. It should call :obj:`~gi.repository.Gtk.ColorDialog.choose_rgba_finish` to obtain the result. .. versionadded:: 4.10 :param parent: the parent ``GtkWindow`` :param initial_color: the color to select initially :param cancellable: a ``GCancellable`` to cancel the operation :param callback: a callback to call when the operation is complete :param user_data: data to pass to ``callback`` .. method:: choose_rgba_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gdk.RGBA | None Finishes the :obj:`~gi.repository.Gtk.ColorDialog.choose_rgba` call and returns the resulting color. .. versionadded:: 4.10 :param result: a ``GAsyncResult`` .. method:: get_modal() -> bool Returns whether the color chooser dialog blocks interaction with the parent window while it is presented. .. versionadded:: 4.10 .. method:: get_title() -> str Returns the title that will be shown on the color chooser dialog. .. versionadded:: 4.10 .. method:: get_with_alpha() -> bool Returns whether colors may have alpha. .. versionadded:: 4.10 .. method:: set_modal(modal: bool) -> None Sets whether the color chooser dialog blocks interaction with the parent window while it is presented. .. versionadded:: 4.10 :param modal: the new value .. method:: set_title(title: str) -> None Sets the title that will be shown on the color chooser dialog. .. versionadded:: 4.10 :param title: the new title .. method:: set_with_alpha(with_alpha: bool) -> None Sets whether colors may have alpha. .. versionadded:: 4.10 :param with_alpha: the new value Properties ---------- .. rst-class:: interim-class .. class:: ColorDialog :no-index: .. attribute:: props.modal :type: bool Whether the color chooser dialog is modal. .. versionadded:: 4.10 .. attribute:: props.title :type: str A title that may be shown on the color chooser dialog that is presented by :obj:`~gi.repository.Gtk.ColorDialog.choose_rgba`. .. versionadded:: 4.10 .. attribute:: props.with_alpha :type: bool Whether colors may have alpha (translucency). When with-alpha is :const:`False`, the color that is selected will be forced to have alpha == 1. .. versionadded:: 4.10