All pastes #209601 Raw Edit

Unnamed

public text v1 · immutable
#209601 ·published 2006-10-19 07:47 UTC
rendered paste body
#!/usr/bin/env python

import pygtk
pygtk.require('2.0')

import gtk
import gnomeapplet
import gobject

def background_show(applet):
    print "background: ", applet.get_background()

def sample_factory(applet, iid):
    print "Creating new applet instance"
    label = gtk.Label("Success!")
    applet.add(label)
    applet.show_all()
    #gobject.timeout_add(1000, background_show, applet)
    #print dir(applet)
    return True

print "Starting factory"
gnomeapplet.bonobo_factory("OAFIID:GNOME_PythonAppletSample_Factory", 
                           gnomeapplet.Applet.__gtype__, 
                           "hello", "0", sample_factory)
print "Factory ended"


"""ghia=gtk.Window()
sample_factory(ghia,3)
ghia.show_all()
gtk.main()"""



<oaf_info>

<oaf_server iid="OAFIID:GNOME_PythonAppletSample_Factory"
            type="exe"
            location="/home/pete/applet/applet.py">

        <oaf_attribute name="repo_ids" type="stringv">
                <item value="IDL:Bonobo/GenericFactory:1.0"/>
                <item value="IDL:Bonobo/Unknown:1.0"/>
        </oaf_attribute>
        <oaf_attribute name="name" type="string" value="PythonAppletSample"/>
        <oaf_attribute name="description" type="string" value="Python Applet Sample"/>
</oaf_server>

<oaf_server iid="OAFIID:GNOME_PythonAppletSample"
            type="factory" 
            location="OAFIID:GNOME_PythonAppletSample_Factory">

        <oaf_attribute name="repo_ids" type="stringv">
                <item value="IDL:GNOME/Vertigo/PanelAppletShell:1.0"/>
                <item value="IDL:Bonobo/Control:1.0"/>
                <item value="IDL:Bonobo/Unknown:1.0"/>
        </oaf_attribute>
        <oaf_attribute name="name" type="string" value="PythonAppletSample"/>
        <oaf_attribute name="description" type="string" value="Python Applet Sample"/>
        <oaf_attribute name="panel:category" type="string" value="Utility"/>
        <oaf_attribute name="panel:icon" type="string" value="bug-buddy.png"/>
</oaf_server>

</oaf_info>