Question

I would like to make a panel-like application, in appearance much like the gnome-panel. I would like to use GTK for this (although i've looked into Qt), preferably using Python.

How can i decorate the window in such a way a color/gradient/bitmap/svg is applied to it?

Was it helpful?

Solution

One way is to use styles (the example below uses inline style strings):

#!/usr/bin/env python

import gtk

pixmap_rc = """
pixmap_path "/home/foo/images"
style "bar" {
    bg_pixmap[NORMAL] = "logo.svg"
} widget "*foo" style "bar"
"""

color_rc= """
style "bar" {
    bg[NORMAL] = "Hot Pink"
} widget "*foo" style "bar"
"""

def main ():
    window = gtk.Window()
    window.set_decorated(False)
    window.connect("destroy", gtk.main_quit)

    window.set_name("foo")
    gtk.rc_parse_string(color_rc)

    window.show_all()
    gtk.main()

if __name__ == "__main__":
    main ()

Setting color gradient via gtkrc seems to be engine-specific, though.

Edit: here goes minimalistic gtkrc example with stretched background image:

pixmap_path "/home/foo/images"
style "bar" {
    engine "pixmap" {
        image {
            function = FLAT_BOX
            file     = "test.png"
            stretch  = TRUE
        }
    }
} widget "*foo" style "bar"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top