2011-10-31 19:56:13 +01:00
|
|
|
from gi.repository import Gtk
|
2013-04-03 22:01:15 +02:00
|
|
|
from sugar3.graphics.alert import TimeoutAlert
|
2017-01-11 18:23:08 +01:00
|
|
|
from common import set_theme
|
2011-10-31 19:56:13 +01:00
|
|
|
|
2017-01-05 01:02:26 +01:00
|
|
|
|
2018-02-08 13:15:15 +01:00
|
|
|
set_theme()
|
2011-10-31 19:56:13 +01:00
|
|
|
w = Gtk.Window()
|
2017-01-11 18:23:08 +01:00
|
|
|
w.connect("delete-event", Gtk.main_quit)
|
|
|
|
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
2011-10-31 19:56:13 +01:00
|
|
|
w.add(box)
|
|
|
|
|
2018-02-08 13:15:15 +01:00
|
|
|
# Create a TimeoutAlert Object
|
|
|
|
alert = TimeoutAlert(5)
|
|
|
|
alert.props.title = '<Alert Title>'
|
|
|
|
alert.props.msg = '<Alert Message>'
|
|
|
|
|
|
|
|
# Add Timeout Object to the box
|
2011-10-31 19:56:13 +01:00
|
|
|
box.pack_start(alert, False, False, 0)
|
|
|
|
|
|
|
|
|
2018-02-08 13:15:15 +01:00
|
|
|
# Called when an alert object throws a response event.
|
|
|
|
def __alert_response_cb(alert, response_id):
|
|
|
|
if response_id is Gtk.ResponseType.OK:
|
2018-03-01 12:58:56 +01:00
|
|
|
print('Continue Button was clicked.')
|
2018-02-08 13:15:15 +01:00
|
|
|
elif response_id is Gtk.ResponseType.CANCEL:
|
2018-03-01 12:58:56 +01:00
|
|
|
print('Cancel Button was clicked.')
|
2018-02-08 13:15:15 +01:00
|
|
|
elif response_id == -1:
|
2018-03-01 12:58:56 +01:00
|
|
|
print('Timeout occurred')
|
2018-02-08 13:15:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
alert.connect('response', __alert_response_cb)
|
|
|
|
w.show_all()
|
2011-10-31 19:56:13 +01:00
|
|
|
Gtk.main()
|