Notification
Added in version 2.40.
Superclasses: Object
- Constructors:
Notification(**properties)
new(title:str) -> Gio.Notification
Constructors
- class Notification
- classmethod new(title: str) Notification
Creates a new
Notification
withtitle
as its title.After populating
notification
with more details, it can be sent to the desktop shell withsend_notification()
. Changing any properties after this call will not have any effect until resendingnotification
.Added in version 2.40.
- Parameters:
title – the title of the notification
Methods
- class Notification
- add_button(label: str, detailed_action: str) None
Adds a button to
notification
that activates the action indetailed_action
when clicked. That action must be an application-wide action (starting with “app.”). Ifdetailed_action
contains a target, the action will be activated with that target as its parameter.See
parse_detailed_name()
for a description of the format fordetailed_action
.Added in version 2.40.
- Parameters:
label – label of the button
detailed_action – a detailed action name
- add_button_with_target(label: str, action: str, target: Variant | None = None) None
Adds a button to
notification
that activatesaction
when clicked.action
must be an application-wide action (it must start with “app.”).If
target_format
is given, it is used to collect remaining positional parameters into aVariant
instance, similar tonew()
.action
will be activated with thatVariant
as its parameter.Added in version 2.40.
- Parameters:
label – label of the button
action – an action name
target
- set_body(body: str | None = None) None
Sets the body of
notification
tobody
.Added in version 2.40.
- Parameters:
body – the new body for
notification
, orNone
- set_category(category: str | None = None) None
Sets the type of
notification
tocategory
. Categories have a main type likeemail
,im
ordevice
and can have a detail separated by a.
, e.g.im.received
oremail.arrived
. Setting the category helps the notification server to select proper feedback to the user.Standard categories are listed in the specification.
Added in version 2.70.
- Parameters:
category – the category for
notification
, orNone
for no category
- set_default_action(detailed_action: str) None
Sets the default action of
notification
todetailed_action
. This action is activated when the notification is clicked on.The action in
detailed_action
must be an application-wide action (it must start with “app.”). Ifdetailed_action
contains a target, the given action will be activated with that target as its parameter. Seeparse_detailed_name()
for a description of the format fordetailed_action
.When no default action is set, the application that the notification was sent on is activated.
Added in version 2.40.
- Parameters:
detailed_action – a detailed action name
- set_default_action_and_target(action: str, target: Variant | None = None) None
Sets the default action of
notification
toaction
. This action is activated when the notification is clicked on. It must be an application-wide action (it must start with “app.”).If
target_format
is given, it is used to collect remaining positional parameters into aVariant
instance, similar tonew()
.action
will be activated with thatVariant
as its parameter.When no default action is set, the application that the notification was sent on is activated.
Added in version 2.40.
- Parameters:
action – an action name
target
- set_icon(icon: Icon) None
Sets the icon of
notification
toicon
.Added in version 2.40.
- Parameters:
icon – the icon to be shown in
notification
, as aIcon
- set_priority(priority: NotificationPriority) None
Sets the priority of
notification
topriority
. SeeNotificationPriority
for possible values.- Parameters:
priority – a
NotificationPriority
- set_title(title: str) None
Sets the title of
notification
totitle
.Added in version 2.40.
- Parameters:
title – the new title for
notification
- set_urgent(urgent: bool) None
Deprecated in favor of
set_priority()
.Added in version 2.40.
Deprecated since version 2.42: Since 2.42, this has been deprecated in favour of
set_priority()
.- Parameters:
urgent –
True
ifnotification
is urgent