Files
sugar-toolkit-gtk3/examples/alert.py
T

34 lines
860 B
Python
Raw Normal View History

from gi.repository import Gtk
2013-04-03 22:01:15 +02:00
from sugar3.graphics.alert import TimeoutAlert
2017-01-11 14:23:08 -03:00
from common import set_theme
2017-01-04 21:02:26 -03:00
set_theme()
w = Gtk.Window()
2017-01-11 14:23:08 -03:00
w.connect("delete-event", Gtk.main_quit)
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
w.add(box)
# Create a TimeoutAlert Object
alert = TimeoutAlert(5)
alert.props.title = '<Alert Title>'
alert.props.msg = '<Alert Message>'
# Add Timeout Object to the box
box.pack_start(alert, False, False, 0)
# 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 17:28:56 +05:30
print('Continue Button was clicked.')
elif response_id is Gtk.ResponseType.CANCEL:
2018-03-01 17:28:56 +05:30
print('Cancel Button was clicked.')
elif response_id == -1:
2018-03-01 17:28:56 +05:30
print('Timeout occurred')
alert.connect('response', __alert_response_cb)
w.show_all()
Gtk.main()