:right-sidebar: True Prompt =================================================================== .. currentmodule:: gi.repository.Gcr .. class:: Prompt(*args, **kwargs) :no-contents-entry: Implementations: :class:`~gi.repository.Gcr.SystemPrompt` A prompt displayed to the user. It is an interface with various implementations. Various properties are set on the prompt, and then the prompt is displayed the various prompt methods like :obj:`~gi.repository.Prompt.password_run`\. A ``GcrPrompt`` may be used to display multiple related prompts. Most implementions do not hide the window between display of multiple related prompts, and the :obj:`~gi.repository.Gcr.Prompt` must be closed or destroyed in order to make it go away. This allows the user to see that the prompts are related. Use ``GcrPromptDialog`` (part of gcr-ui) to create an in-process GTK+ dialog prompt. Use :obj:`~gi.repository.Gcr.SystemPrompt` to create a system prompt in a prompter process. The prompt implementation will always display the :obj:`~gi.repository.Gcr.Prompt.props.message` property, but may choose not to display the :obj:`~gi.repository.Gcr.Prompt.props.description` or :obj:`~gi.repository.Gcr.Prompt.props.title` properties. Methods ------- .. rst-class:: interim-class .. class:: Prompt :no-index: .. method:: close() -> None Closes the prompt so that in can no longer be used to prompt. The various prompt methods will return results as if the user dismissed the prompt. The prompt may also be closed by the implementor of the prompt object. This emits the :obj:`~gi.repository.Gcr.Prompt.signals.prompt_close` signal on the prompt object. .. method:: confirm(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gcr.PromptReply Prompts for confirmation asking a cancel/continue style question. Set the various properties on the prompt before calling this function to represent the question correctly. This method will block until the a response is returned from the prompter. :const:`~gi.repository.Gcr.PromptReply.CONTINUE` will be returned if the user confirms the prompt. The return value will also be :const:`~gi.repository.Gcr.PromptReply.CANCEL` if the user cancels or if an error occurs. Check the ``error`` argument to tell the difference. :param cancellable: optional cancellation object .. method:: confirm_async(cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Prompts for confirmation asking a cancel/continue style question. Set the various properties on the prompt before calling this method to represent the question correctly. This method will return immediately and complete asynchronously. :param cancellable: optional cancellation object :param callback: called when the operation completes :param user_data: data to pass to the callback .. method:: confirm_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gcr.PromptReply Complete an operation to prompt for confirmation. :const:`~gi.repository.Gcr.PromptReply.CONTINUE` will be returned if the user confirms the prompt. The return value will also be :const:`~gi.repository.Gcr.PromptReply.CANCEL` if the user cancels or if an error occurs. Check the ``error`` argument to tell the difference. :param result: asynchronous result passed to callback .. method:: confirm_run(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gcr.PromptReply Prompts for confirmation asking a cancel/continue style question. Set the various properties on the prompt before calling this function to represent the question correctly. This method will block until the a response is returned from the prompter and will run a main loop similar to a ``gtk_dialog_run()``\. The application will remain responsive but care must be taken to handle reentrancy issues. :const:`~gi.repository.Gcr.PromptReply.CONTINUE` will be returned if the user confirms the prompt. The return value will also be :const:`~gi.repository.Gcr.PromptReply.CANCEL` if the user cancels or if an error occurs. Check the ``error`` argument to tell the difference. :param cancellable: optional cancellation object .. method:: get_caller_window() -> str Get the string handle of the caller's window. The caller window indicates to the prompt which window is prompting the user. The prompt may choose to ignore this information or use it in whatever way it sees fit. .. method:: get_cancel_label() -> str Get the label for the cancel button. This is the button that results in a :const:`~gi.repository.Gcr.PromptReply.CANCEL` reply from the prompt. .. method:: get_choice_chosen() -> bool Get whether the additional choice was chosen or not. The additional choice would have been setup using :func:`~gi.repository.Gcr.Prompt.set_choice_label`. .. method:: get_choice_label() -> str Get the label for the additional choice. This will be :const:`None` if no additional choice is being displayed. .. method:: get_continue_label() -> str Get the label for the continue button. This is the button that results in a :const:`~gi.repository.Gcr.PromptReply.CONTINUE` reply from the prompt. .. method:: get_description() -> str Get the detailed description of the prompt. A prompt implementation may choose not to display this detailed description. The prompt message should contain relevant information. .. method:: get_message() -> str Gets the prompt message for the user. A prompt implementation should always display this message. .. method:: get_password_new() -> bool Get whether the prompt will prompt for a new password. This will cause the prompt implementation to ask the user to confirm the password and/or display other relevant user interface for creating a new password. .. method:: get_password_strength() -> int Get indication of the password strength. Prompts will return a zero value if the password is empty, and a value greater than zero if the password has any characters. This is only valid after a successful prompt for a password. .. method:: get_title() -> str Gets the title of the prompt. A prompt implementation may choose not to display the prompt title. The prompt message should contain relevant information. .. method:: get_warning() -> str Get a prompt warning displayed on the prompt. This is a warning like "The password is incorrect." usually displayed to the user about a previous 'unsuccessful' prompt. If this string is :const:`None` then no warning is displayed. .. method:: password(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> str Prompts for password. Set the various properties on the prompt before calling this method to explain which password should be entered. This method will block until the a response is returned from the prompter. A password will be returned if the user enters a password successfully. The returned password is valid until the next time a method is called to display another prompt. :const:`None` will be returned if the user cancels or if an error occurs. Check the ``error`` argument to tell the difference. :param cancellable: optional cancellation object .. method:: password_async(cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Prompts for password. Set the various properties on the prompt before calling this method to explain which password should be entered. This method will return immediately and complete asynchronously. :param cancellable: optional cancellation object :param callback: called when the operation completes :param user_data: data to pass to the callback .. method:: password_finish(result: ~gi.repository.Gio.AsyncResult) -> str Complete an operation to prompt for a password. A password will be returned if the user enters a password successfully. The returned password is valid until the next time a method is called to display another prompt. :const:`None` will be returned if the user cancels or if an error occurs. Check the ``error`` argument to tell the difference. :param result: asynchronous result passed to callback .. method:: password_run(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> str Prompts for password. Set the various properties on the prompt before calling this method to explain which password should be entered. This method will block until the a response is returned from the prompter and will run a main loop similar to a gtk_dialog_run(). The application will remain responsive but care must be taken to handle reentrancy issues. A password will be returned if the user enters a password successfully. The returned password is valid until the next time a method is called to display another prompt. :const:`None` will be returned if the user cancels or if an error occurs. Check the ``error`` argument to tell the difference. :param cancellable: optional cancellation object .. method:: reset() -> None Reset the contents and properties of the prompt. .. method:: set_caller_window(window_id: str) -> None Set the string handle of the caller's window. The caller window indicates to the prompt which window is prompting the user. The prompt may choose to ignore this information or use it in whatever way it sees fit. :param window_id: the window id .. method:: set_cancel_label(cancel_label: str) -> None Set the label for the continue button. This is the button that results in a :const:`~gi.repository.Gcr.PromptReply.CANCEL` reply from the prompt. :param cancel_label: the label .. method:: set_choice_chosen(chosen: bool) -> None Set whether the additional choice is chosen or not. The additional choice should be set up using :func:`~gi.repository.Gcr.Prompt.set_choice_label`. :param chosen: whether chosen .. method:: set_choice_label(choice_label: str | None = None) -> None Set the label for the additional choice. If this is a non-:const:`None` value then an additional boolean choice will be displayed by the prompt allowing the user to select or deselect it. The initial value of the choice can be set with the :func:`~gi.repository.Gcr.Prompt.set_choice_label` method. If this is :const:`None`, then no additional choice is being displayed. :param choice_label: the additional choice or :const:`None` .. method:: set_continue_label(continue_label: str) -> None Set the label for the continue button. This is the button that results in a :const:`~gi.repository.Gcr.PromptReply.CONTINUE` reply from the prompt. :param continue_label: the label .. method:: set_description(description: str) -> None Set the detailed description of the prompt. A prompt implementation may choose not to display this detailed description. Use :func:`~gi.repository.Gcr.Prompt.set_message` to set a general message containing relevant information. :param description: the detailed description .. method:: set_message(message: str) -> None Sets the prompt message for the user. A prompt implementation should always display this message. :param message: the prompt message .. method:: set_password_new(new_password: bool) -> None Set whether the prompt will prompt for a new password. This will cause the prompt implementation to ask the user to confirm the password and/or display other relevant user interface for creating a new password. :param new_password: whether in new password mode or not .. method:: set_title(title: str) -> None Sets the title of the prompt. A prompt implementation may choose not to display the prompt title. The prompt message should contain relevant information. :param title: the prompt title .. method:: set_warning(warning: str | None = None) -> None Set a prompt warning displayed on the prompt. This is a warning like "The password is incorrect." usually displayed to the user about a previous 'unsuccessful' prompt. If this string is :const:`None` then no warning is displayed. :param warning: the warning or :const:`None` Properties ---------- .. rst-class:: interim-class .. class:: Prompt :no-index: .. attribute:: props.caller_window :type: str The type of the None singleton. .. attribute:: props.cancel_label :type: str The type of the None singleton. .. attribute:: props.choice_chosen :type: bool The type of the None singleton. .. attribute:: props.choice_label :type: str The type of the None singleton. .. attribute:: props.continue_label :type: str The type of the None singleton. .. attribute:: props.description :type: str The type of the None singleton. .. attribute:: props.message :type: str The type of the None singleton. .. attribute:: props.password_new :type: bool The type of the None singleton. .. attribute:: props.password_strength :type: int The type of the None singleton. .. attribute:: props.title :type: str The type of the None singleton. .. attribute:: props.warning :type: str The type of the None singleton. Signals ------- .. rst-class:: interim-class .. class:: Prompt.signals :no-index: .. method:: prompt_close() -> None The type of the None singleton. Virtual Methods --------------- .. rst-class:: interim-class .. class:: Prompt :no-index: .. method:: do_prompt_close() -> None The type of the None singleton. .. method:: do_prompt_confirm_async(cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None The type of the None singleton. :param cancellable: optional cancellation object :param callback: called when the operation completes :param user_data: data to pass to the callback .. method:: do_prompt_confirm_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gcr.PromptReply The type of the None singleton. :param result: asynchronous result passed to callback .. method:: do_prompt_password_async(cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None The type of the None singleton. :param cancellable: optional cancellation object :param callback: called when the operation completes :param user_data: data to pass to the callback .. method:: do_prompt_password_finish(result: ~gi.repository.Gio.AsyncResult) -> str The type of the None singleton. :param result: asynchronous result passed to callback