Sample Code 9: How to put a border around GtkLabel?
Written by kksou
Wednesday, 13 September 2006
You want to achieve the following:
- Create a GtkFrame
- Place the label in the frame
- Set the background color of the frame with modify_bg which will become the color of the border
| 1 |
$window = &new GtkWindow();
$window->connect_simple('destroy', array( 'Gtk', 'main_quit'));
// create a vbox to hold multiple labels
$vbox = new GtkVBox();
$frame = new GtkFrame();
$frame->modify_bg(Gtk::STATE_NORMAL, GdkColor::parse('#0000ff')); // note 1
// create the title label and stuff it in the eventbox
$title = new GtkLabel('This is the title');
$vbox->pack_start($frame, 0, 0); // note 2
- Note that this is only 70% of the sample code. You have to be a registered member to see the entire sample code. Please login or register.
- Registration is free and immediate.
- Have some doubt about the registration? Please read this forum article.
You can add a border to GtkLabel with GtkFrame.
Note 1: this sets the color of the border. Note the use of modify_bg and not
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.
You may want to compare this with setting background color of GtkLabel. The concept is exactly the same, except a border uses GtkFrame, and setting background color uses eventbox.