Changing background color of an editable gtk widget
Okay it seems to work fine with labels, entry, objects, but gtkTextView objects appear by default to retain default 'white' background. Tried several methods for changing background using event box, but it appears color or pixmap images are rendered occluded (blocked) by gtkTextView objects background...hmm...still looking for solution on this.
Easy method for changing background with pixmap image with pygtk 2+...should work in gtk3+ as well
winstyle = window.get_style().copy()
pixbuf = gtk.gdk.pixbuf_new_from_file(filepath)
pixmap, mask = pixbuf.render_pixmap_and_mask()
winstyle.bg_pixmap[gtk.STATE_NORMAL] = pixmap
window.set_style(winstyle)
If you are working with glade you can find the widow style by referencing your ui top level window...
for example,
a window called mydialog, would have its style referenced as above using
winstyle = self.ui.mydialog.get_style().copy()
just need to substitute 'self.ui.mydialog' for 'window' above
and 'filepath' refers to path to pixmap file (I typically use .png files).
Sunday, March 25, 2012
Subscribe to:
Post Comments (Atom)
A long time
The years have passed. Life presents all the new challenges and stresses. I am thinking of the Ship of Theseus and re-examining this ...
-
from gi.repository import Gtk, Gdk, cairo, Pango, PangoCairo import math import sys RADIUS = 150 N_WORDS = 10 FONT = "Sans Bold 27...
-
I've looked through a series of web sites on this topic, any number of these ranging in various degrees of technical information, but...
-
I recently decided to do some work on Ogre again. Here are some recent encounters...and work around that could help for starting. S...
No comments:
Post a Comment