2.6 Center the button horizontally and vertically |
|
Written by kksou
|
|
Thursday, 20 March 2008 |
|
Objective
You have centered the button horizontally in the previous example as shown below:

What if you want the button to be centered both horizontally and vertically?
Overview
In addition to the two spring boxes left and right, we stuff two more top and below too as illustrated below:

Sample Output

Sample Code
1 2 3 4 5 6 7 8 9 10 11 12 13
| <?php $window = new GtkWindow(); $window->connect_simple('destroy',array('Gtk','main_quit')); $window->set_size_request(200, 100); $vbox = new GtkVBox(); $window->add($vbox);
$button = new GtkButton('button label'); $hbox = new GtkHBox(); $hbox->pack_start(new GtkLabel(), true); // note 1
$hbox->pack_start($button, false); $hbox->pack_start(new GtkLabel(), true); // note 1
|
- 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.
Explanation
- The spring boxes left and right.
- The spring boxes top and bottom.
User reviews There are no user reviews yet. Note: You have to be a registered member to leave a comment. Free registration here. |
|