9
def background_show(applet):
10
print "background: ", applet.get_background()
12
def sample_factory(applet, iid):
13
print "Creating new applet instance"
14
label = gtk.Label("Success!")
17
gobject.timeout_add(1000, background_show, applet)
18
"""The main applet wrapper."""
19
def __init__(self, applet, iid):
22
self._button = gtk.ToggleButton("Sample Very Very Long String")
23
self._button.connect("button_press_event", self.do_not_eat_button_press)
24
self._button.connect("clicked", self.on_button_clicked)
25
self._applet.add(self._button)
27
self._applet.setup_menu("""
28
<popup name="button3">
29
<menuitem name="About" verb="About" _label="_About" pixtype="stock" pixname="gtk-about"/>
32
("About", lambda a, b: self.on_show_about(a))
35
self._applet.connect("destroy", self.on_applet_destroyed)
36
self._applet.show_all()
40
def do_not_eat_button_press(self, widget, event):
42
widget.stop_emission("button_press_event")
46
def on_applet_destroyed(self, *args):
49
def on_button_clicked(self, button, *args):
50
print "Button clicked!"
52
def on_show_about(self, *args):
55
def applet_factory(applet, iid):
20
#print "Starting factory"
21
#gnomeapplet.bonobo_factory("OAFIID:GNOME_PythonAppletSample_Factory",
22
# gnomeapplet.Applet.__gtype__,
23
# "hello", "0", sample_factory)
24
#print "Factory ended"
25
main_window = gtk.Window(gtk.WINDOW_TOPLEVEL)
26
main_window.set_title("Python Applet")
27
main_window.connect("destroy", gtk.main_quit)
28
app = gnomeapplet.Applet()
29
sample_factory(app, None)
30
app.reparent(main_window)
31
main_window.show_all()
60
main_window = gtk.Window(gtk.WINDOW_TOPLEVEL)
61
main_window.set_title("Applet")
62
main_window.connect("destroy", gtk.main_quit)
63
app = gnomeapplet.Applet()
64
applet_factory(app, None)
65
app.reparent(main_window)
66
main_window.show_all()
69
def initialize_applet():
70
gnomeapplet.bonobo_factory("OAFIID:NotifyLogApplet_Factory",
71
gnomeapplet.Applet.__gtype__,
72
"hello", "0", applet_factory)
78
if __name__ == '__main__':