2.5 Center the button horizontally |
|
Written by kksou
|
|
Wednesday, 19 March 2008 |
|
Objective
You have right aligned the button in the previous example as shown below:

What if you want the button to be centered horizontally?
Overview
Instead of stuffing one spring box, we stuff two – one on each side as illustrated below:

Sample Output

Sample Code
1 2 3 4 5 6 7 8 9 10 11
| <?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 GtkHBox(), true); // note 1
$hbox->pack_start($button, false);
|
- 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
- This is the spring box on the left. Just for illustration sake, we use a hbox here to show you that the effect is the same as using an empty GtkLabel.
- This is the spring box on the right. Just for illustration sake, we use a vbox here to show you that the effect is the same as using an empty GtkLabel.
User reviews There are no user reviews yet. Note: You have to be a registered member to leave a comment. Free registration here. |
|