1
votes

I got a problem to set the transparent background of drawing area.

The reason what I want this is that I have a main window where is background

def draw_pixbuf(self,widget, event):
    path = 'test.jpg'
    pixbuf = gtk.gdk.pixbuf_new_from_file(path)
    scaled_buf = pixbuf.scale_simple(800,480,gtk.gdk.INTERP_BILINEAR)
    widget.window.draw_pixbuf(widget.style.bg_gc[gtk.STATE_NORMAL],    scaled_buf, 0, 0, 0,0)
self.window = gtk.Window()
self.window.connect("delete-event", gtk.main_quit)
self.window.set_decorated(False)
self.window.set_position(gtk.WIN_POS_CENTER_ALWAYS)
self.window.set_size_request(800,480)
hbbox = gtk.HBox()
hbbox.connect('expose-event', self.draw_pixbuf)

so my HBox has this background and I have two Fixed containers in it - one button and one drawing area.

fix = gtk.Fixed()
image = gtk.Image()
image.set_from_file("close.png")
event_box = gtk.EventBox()
event_box.add(image)
event_box.set_size_request(30,30)
event_box.set_visible_window(False)
event_box.connect("button_press_event",gtk.mainquit)
fix.put(event_box,140,0)

self.darea = gtk.DrawingArea()

self.darea.set_size_request(450,300)  
self.darea.connect("expose-event", self.expose)
fix2 = gtk.Fixed()
fix2.put(self.darea,175,90)
hbbox.pack_start(fix2, True, False, 10)
hbbox.pack_end(fix, True, False, 10)
#hbbox.pack_start(self.darea,True,False,10)
self.window.add(hbbox)
self.window.show_all()

But the drawing area overrides that HBox's background with its own default background(grey). I am able to change background by modify_bg function, but I want it transparent to write the cairo animated text on the HBox's background.

So the goal is to have background image of the window and draw the caito animated text onto it and not to grey rectangle (drawing area's background).

I am new to GTK so maybe I miss something important how to do it.

I hope you can help. Thank you.

1
Is this GTK+ 2 or GTK+ 3?andlabs

1 Answers

1
votes

I also have not found solution and swiched to Cairo (Pycairo)

See more there: GTK drawable area transparent background color