from gi.repository import GVnc, GtkVnc, Gtk, GLib from gi.repository import Notify import sys def notify(obj, v): n = Notify.Notification( summary="Connected to %(host)s" % v, body="Made VNC connection to " "server %(host)s at port %(port)s" % v) if hint: n.set_hint(hint, GLib.Variant('b', True)) n.show() try: hint = 'resident' if sys.argv[1].startswith('r') else 'transient' print "Making notificaionts %s" % hint except: hint = None vncserver = dict(host='localhost', port='5901') Gtk.init(None) Notify.init("GTK-VNC with Python") win = Gtk.Window(title="GTK-VNC with Python") disp = GtkVnc.Display() disp.connect("vnc-connected", notify, vncserver) win.add(disp) win.connect('delete-event', Gtk.main_quit) disp.open_host(vncserver['host'], vncserver['port']) win.show_all() Gtk.main()