Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A simple solution like HTML widgets and a transparent Webkit window would be ideal.

I'm trying to make a simple background widget framework such that I can easily customize my desktop with some CSS widgets and not worry about the separate undecorated windows getting moved around like with screenlets on setsid unity.

Something like this but with pygi is what I'm looking to find.

share|improve this question
up vote 6 down vote accepted

Here's some working code for a transparent WebKit window.

from gi.repository import WebKit, Gtk, Gdk
import signal

class BackgroundPaneCallbacks:

class BackgroundPaneWebview(WebKit.WebView):
    def __init__(self):
        self.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0,0,0,0))
                              '<STYLE type="text/css">'+\
                              'BODY { background: rgba(0,0,0,0);}'+\
                              'Hello World'+\
        print("Webview loaded")

class BackgroundPaneWin(Gtk.Window):
    def __init__(self, address="", port=54541):

        #Set transparency
        screen = self.get_screen()
        rgba = screen.get_rgba_visual()
        self.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0,0,0,0))

        #Add all the parts
        self.view = BackgroundPaneWebview()
        box = Gtk.Box()
        box.pack_start(self.view, True, True, 0)
        self.connect("destroy", lambda q: Gtk.main_quit())

        #Show all the parts

        print("Win loaded")

class BackgroundPane:
    def __init__(self, params=False):
        #Add all the parts
        self.root = params['root'] = BackgroundPaneWin()
        print("Pane loaded")

    def init(self):

    def add_widget(self, widget):

class Logger:
    def __init__(self, root):
        self.root = root
        self.log("Logger loaded")

    def log(self, msg, level='console'):
        if level=='console':
            print msg

class Handlers:

class App:
    def __init__(self, params={}):
        #Get screen geometry
        s = Gdk.Screen.get_default()
        params['w'] = s.get_width()
        params['h'] = s.get_height()

        #Store params
        self.params = params
        self.log = Logger(self).log
        self.handlers = Handlers()
        #Get all components
        bg = BackgroundPane({'root':self,
        #Store all components
        self.components = {}
        self.components['bg'] = bg

        #Make sure everything is started

        #Make sure Ctl-C works
        signal.signal(signal.SIGINT, signal.SIG_DFL)

    def run(self):

if __name__ == '__main__':
    print("Loading app...")
    app = App()
share|improve this answer
This is nice, but if you want the widget to ignore the "Show Desktop" Plugin, see the answer here:… – Ian B. Feb 25 '13 at 14:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.