sugar4.graphics.alert
Alerts appear in an activity below the toolbox and above the canvas.
Alert and the derived TimeoutAlert,
ConfirmationAlert, ErrorAlert, and
NotifyAlert, each have a title, a message and optional
buttons.
Alert will emit a response signal when a button is
clicked.
The TimeoutAlert and NotifyAlert display a countdown
and will emit a response signal when a timeout occurs.
Example
Create a simple alert message.
from sugar4.graphics.alert import Alert
# Create a new simple alert
alert = Alert()
# Set the title and text body of the alert
alert.props.title = _('Title of Alert Goes Here')
alert.props.msg = _('Text message of alert goes here')
# Add the alert to the activity
self.add_alert(alert)
alert.show()
STABLE.
Classes
Alerts are inside the activity window instead of being a |
|
An alert with two buttons; Ok and Cancel. |
|
An alert with one button; Ok. |
|
A timed alert with two buttons; Continue and Cancel. The Continue |
|
A timed alert with one button; Ok. The button contains a |
Module Contents
- class sugar4.graphics.alert.Alert(**kwargs)[source]
Bases:
gi.repository.Gtk.BoxAlerts are inside the activity window instead of being a separate popup window. They do not hide the canvas.
Use
add_alert()andremove_alert()to add and remove an alert. These methods are inherited by anActivityvia superclassWindow.The alert is placed between the canvas and the toolbox, or above the canvas in fullscreen mode.
- Parameters:
- do_set_property(pspec, value)[source]
Set alert property, GObject internal method. Use the alert.props object, eg:
alert.props.title = 'Are you happy?'
- do_get_property(pspec)[source]
Get alert property, GObject internal method. Use the alert.props object, eg:
title = alert.props.title
- add_entry()[source]
Create an entry and add it to the alert.
The entry is placed after the title and before the buttons.
Caller is responsible for capturing the entry text in the response signal handler or a
Gtk.Entrysignal handler.- Returns:
the entry added to the alert
- Return type:
- add_button(response_id, label, icon=None, position=-1)[source]
Create a button and add it to the alert.
The button is added to the end of the alert.
When the button is clicked, the response signal will be emitted, along with a response identifier.
- Parameters:
- Returns:
the button added to the alert
- Return type:
- remove_button(response_id)[source]
Remove a button from the alert.
The button is selected for removal using the response identifier that was passed to
add_button().- Parameters:
response_id (int) – the response identifier
- Returns:
None
- class sugar4.graphics.alert.ConfirmationAlert(**kwargs)[source]
Bases:
AlertAn alert with two buttons; Ok and Cancel.
When a button is clicked, the
ConfirmationAlertwill emit a response signal with a response identifier. For the Ok button, the response identifier will beGtk.ResponseType.OK. For the Cancel button,Gtk.ResponseType.CANCEL.- Parameters:
**kwargs – parameters for
Alert
- class sugar4.graphics.alert.ErrorAlert(**kwargs)[source]
Bases:
AlertAn alert with one button; Ok.
When the button is clicked, the
ErrorAlertwill emit a response signal with a response identifierGtk.ResponseType.OK.- Parameters:
**kwargs – parameters for
Alert
- class sugar4.graphics.alert.TimeoutAlert(timeout=5, **kwargs)[source]
Bases:
_TimeoutAlertA timed alert with two buttons; Continue and Cancel. The Continue button contains a countdown of seconds remaining.
When a button is clicked, the
TimeoutAlertwill emit a response signal with a response identifier. For the Continue button, the response identifier will beGtk.ResponseType.OK. For the Cancel button,Gtk.ResponseType.CANCEL.If the countdown reaches zero before a button is clicked, the
TimeoutAlertwill emit a response signal with a response identifier of -1.
- class sugar4.graphics.alert.NotifyAlert(timeout=5, **kwargs)[source]
Bases:
_TimeoutAlertA timed alert with one button; Ok. The button contains a countdown of seconds remaining.
When the button is clicked, the
NotifyAlertwill emit a response signal with a response identifierGtk.ResponseType.OK.If the countdown reaches zero before the button is clicked, the
NotifyAlertwill emit a response signal with a response identifier of -1.