Writing an applet in languages other than C: Panel Applet Reference Manual

## Writing an applet in languages other than C

The Panel Applet library comes with support for GObject Introspection. This makes it possible to write applets in the languages that have bindings based on GObject Introspection.

Here is a simple example of a python applet:

Example 4. Hello World applet, in Python

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    from gi.repository import Gtk
    from gi.repository import PanelApplet

    def applet_fill(applet):
        label = Gtk.Label("Hello World")
        applet.add(label)
        applet.show_all()

    def applet_factory(applet, iid, data):
        if iid != "HelloWorldApplet":
           return False

        applet_fill(applet)

        return True

    PanelApplet.Applet.factory_main("HelloWorldFactory",
                                    PanelApplet.Applet.__gtype__,
                                    applet_factory, None)

The only limitation of writing an applet in a language other than C is that the applet will not be able to run in the panel process: it will have to stay out-of-process. However, since it is recommended to leave applets out-of-process, this limitation is mitigated.