PHP-GTK2 Newsletter
|
Sample Code 8: How to set the background color of GtkLabel? |
| Written by kksou | ||||||
| Wednesday, 13 September 2006 | ||||||
|
Problem You want to achieve the following:
Solution
Sample Code
Explanation
In order to have change the color of a label, one way is to create a GtkEventBox, place the label in it, and change the background color of the eventbox with modify_bg. The net effect is you have a colored label! In the example above, we place the title label in the eventbox and set the background color of the eventbox to yellow. Note 1: this sets the size of the title. Note 2: this make sure that php-gtk doesn't change the size of title. Note 3: this makes the body text stretechable, that is, it will take on whatever space remains below the title. Notes
Note that GtkWindow can only hold one widget at a time. If you need to stuff multiple widgets, use a container widget such as GtkVBox as in this example. User reviews Average user ratings: 3.5 (from 4 users) Note: You have to be a registered member to leave a comment. Free registration here. |
||||||
| < Prev | Next > |
|---|







3.5 (from 4 users)
December 20, 2007 1:34am
thanks
September 23, 2008 10:46pm
January 11, 2009 11:55am
May 30, 2010 11:21pm
Saved me lots of time (again).