Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

The space between boxes should keep different colour

http://ubuntuone.com/756mWfF2hTYwgiGCOccmEz

Something like this

http://ubuntuone.com/3jCDQHtSt6KJfbYQ6YMH7F

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

share|improve this question
add comment

1 Answer

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)
        cr.fill()


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")
        vbox.add(b1)
        vbox.add(b2)
        self.add(vbox)
        self.show_all()


if __name__ == "__main__":
    PyApp()
    gtk.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
add comment

Your Answer

 
discard

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.