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

I need change only background colour of window, and keep widgets in system colours.

The space between boxes should keep different colour

Something like this

I don't know if clutter is here better way to make it look this way

share|improve this question
up vote 3 down vote accepted

You have not specified the programming language, so I assume Python for simplicity reasons.

In gtk, most components can connect to an expose event which can then be used to draw manually into the widget (cairo is used for this, all those widgets have a cairo context attached to them)

Here is a simple example of a window with a custom colored Vbox and two buttons, the space between the bottons (here set to 20 pixels) and the small border around the buttons shows the background color of the VBox.

import gtk

class MyColoredBox(gtk.VBox):
    def __init__(self, homogeneous=False, spacing=0):
        super(MyColoredBox, self).__init__(homogeneous, spacing)
        self.connect("expose-event", self.expose)

    def expose(self, widget, event):
        cr = widget.window.cairo_create()
        cr.set_source_rgb(1.0, 1.0, 0.5)
        cr.rectangle(event.area.x, event.area.y,
                     event.area.width, event.area.height)

class PyApp(gtk.Window):
    def __init__(self):
        super(PyApp, self).__init__()
        self.connect("destroy", gtk.main_quit)
        vbox = MyColoredBox(False, 20)
        b1 = gtk.Button("Hello")
        b2 = gtk.Button("World")

if __name__ == "__main__":

The resulting programm looks something like this: enter image description here

share|improve this answer
Thanks it helped a lot – pavolzetor Nov 6 '11 at 13:37

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.