Notify.Notification

g GObject.Object GObject.Object Notify.Notification Notify.Notification GObject.Object->Notify.Notification

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (summary, body, icon)

add_action (action, label, callback, *user_data)

clear_actions ()

clear_hints ()

close ()

get_activation_token ()

get_closed_reason ()

set_app_name (app_name)

set_category (category)

set_hint (key, value)

set_hint_byte (key, value)

set_hint_byte_array (key, value)

set_hint_double (key, value)

set_hint_int32 (key, value)

set_hint_string (key, value)

set_hint_uint32 (key, value)

set_icon_from_pixbuf (icon)

set_image_from_pixbuf (pixbuf)

set_timeout (timeout)

set_urgency (urgency)

show ()

update (summary, body, icon)

Virtual Methods

Inherited:

GObject.Object (7)

do_closed ()

Properties

Name

Type

Flags

Short Description

app-name

str

r/w

The application name to use for this notification

body

str

r/w/c

The message body text

closed-reason

int

r

The reason code for why the notification was closed

icon-name

str

r/w/c

The icon filename or icon theme-compliant name

id

int

r/w/c

The notification ID

summary

str

r/w/c

The summary text

Signals

Inherited:

GObject.Object (1)

Name

Short Description

closed

Emitted when the notification is closed.

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_object

GObject.Object

r

Class Details

class Notify.Notification(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Notify.NotificationClass

A passive pop-up notification.

Notify.Notification represents a passive pop-up notification. It can contain summary text, body text, and an icon, as well as hints specifying how the notification should be presented. The notification is rendered by a notification daemon, and may present the notification in any number of ways. As such, there is a clear separation of content and presentation, and this API enforces that.

classmethod new(summary, body, icon)
Parameters:
  • summary (str) – The required summary text.

  • body (str or None) – The optional body text.

  • icon (str or None) – The optional icon theme icon name or filename.

Returns:

The new Notify.Notification.

Return type:

Notify.Notification

Creates a new Notify.Notification.

The summary text is required, but all other parameters are optional.

add_action(action, label, callback, *user_data)
Parameters:
  • action (str) – The action ID.

  • label (str) – The human-readable action label.

  • callback (Notify.ActionCallback) – The action’s callback function.

  • user_data (object or None) – Optional custom data to pass to callback.

Adds an action to a notification.

When the action is invoked, the specified callback function will be called, along with the value passed to user_data.

clear_actions()

Clears all actions from the notification.

clear_hints()

Clears all hints from the notification.

close()
Raises:

GLib.Error

Returns:

True on success, or False on error with error filled in

Return type:

bool

Synchronously tells the notification server to hide the notification on the screen.

get_activation_token()
Returns:

The current activation token, or None if none

Return type:

str or None

Gets the activation token of the notification.

If an an action is currently being activated, return the activation token. This function is intended to be used in a [callback`ActionCallback`] to get the activation token for the activated action, if the notification daemon supports it.

New in version 0.7.10.

get_closed_reason()
Returns:

An integer representing the closed reason code (Since 0.8.0 it’s also a [enum`ClosedReason`]).

Return type:

int

Returns the closed reason code for the notification.

This is valid only after the [signal`Notification`:py:func:::closed<Notify.Notification.signals.closed>] signal is emitted.

Since version 0.8.0 the returned value is of type [enum`ClosedReason`].

set_app_name(app_name)
Parameters:

app_name (str or None) – the localised application name

Sets the application name for the notification.

If this function is not called or if app_name is None, the application name will be set from the value used in [func`init`] or overridden with [func`set_app_name`].

New in version 0.7.3.

set_category(category)
Parameters:

category (str) – The category.

Sets the category of this notification.

This can be used by the notification server to filter or display the data in a certain way.

set_hint(key, value)
Parameters:

Sets a hint for key with value value.

If value is None, a previously set hint for key is unset.

If value is floating, it is consumed.

New in version 0.6.

set_hint_byte(key, value)
Parameters:
  • key (str) – The hint.

  • value (int) – The hint’s value.

Sets a hint with a byte value.

Deprecated since version 0.6.: Use [method`Notification`.set_hint] instead

set_hint_byte_array(key, value)
Parameters:
  • key (str) – The hint.

  • value (bytes) – The hint’s value.

Sets a hint with a byte array value.

The length of value must be passed as len.

Deprecated since version 0.6.: Use [method`Notification`.set_hint] instead

set_hint_double(key, value)
Parameters:
  • key (str) – The hint.

  • value (float) – The hint’s value.

Sets a hint with a double value.

Deprecated since version 0.6.: Use [method`Notification`.set_hint] instead

set_hint_int32(key, value)
Parameters:
  • key (str) – The hint.

  • value (int) – The hint’s value.

Sets a hint with a 32-bit integer value.

Deprecated since version 0.6.: Use [method`Notification`.set_hint] instead

set_hint_string(key, value)
Parameters:
  • key (str) – The hint.

  • value (str) – The hint’s value.

Sets a hint with a string value.

Deprecated since version 0.6.: Use [method`Notification`.set_hint] instead

set_hint_uint32(key, value)
Parameters:
  • key (str) – The hint.

  • value (int) – The hint’s value.

Sets a hint with an unsigned 32-bit integer value.

Deprecated since version 0.6.: Use [method`Notification`.set_hint] instead

set_icon_from_pixbuf(icon)
Parameters:

icon (GdkPixbuf.Pixbuf) – The icon.

Sets the icon in the notification from a GdkPixbuf.Pixbuf.

Deprecated since version 0.5.: Use [method`Notification`.set_image_from_pixbuf] instead.

set_image_from_pixbuf(pixbuf)
Parameters:

pixbuf (GdkPixbuf.Pixbuf) – The image.

Sets the image in the notification from a [class`GdkPixbuf`.Pixbuf].

New in version 0.5.

set_timeout(timeout)
Parameters:

timeout (int) – The timeout in milliseconds.

Sets the timeout of the notification.

To set the default time, pass Notify.EXPIRES_DEFAULT as timeout. To set the notification to never expire, pass Notify.EXPIRES_NEVER.

Note that the timeout may be ignored by the server.

set_urgency(urgency)
Parameters:

urgency (Notify.Urgency) – The urgency level.

Sets the urgency level of this notification.

show()
Raises:

GLib.Error

Returns:

True if successful. On error, this will return False and set error.

Return type:

bool

Tells the notification server to display the notification on the screen.

update(summary, body, icon)
Parameters:
  • summary (str) – The new required summary text.

  • body (str or None) – The optional body text.

  • icon (str or None) – The optional icon theme icon name or filename.

Returns:

True, unless an invalid parameter was passed.

Return type:

bool

Updates the notification text and icon.

This won’t send the update out and display it on the screen. For that, you will need to call [method`Notification`.show].

do_closed() virtual

Signal Details

Notify.Notification.signals.closed(notification)
Signal Name:

closed

Flags:

RUN_FIRST

Parameters:

notification (Notify.Notification) – The object which received the signal

Emitted when the notification is closed.

Property Details

Notify.Notification.props.app_name
Name:

app-name

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

The name of the application for the notification.

New in version 0.7.3.

Notify.Notification.props.body
Name:

body

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT

The body of the notification.

Notify.Notification.props.closed_reason
Name:

closed-reason

Type:

int

Default Value:

-1

Flags:

READABLE

The closed reason of the notification.

See [signal`Notification`:py:func:::closed<Notify.Notification.signals.closed>].

Notify.Notification.props.icon_name
Name:

icon-name

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT

The icon-name of the icon to be displayed on the notification.

Notify.Notification.props.id
Name:

id

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, CONSTRUCT

The Id of the notification.

Notify.Notification.props.summary
Name:

summary

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT

The summary of the notification.