PHP-GTK
Friday, November 28, 2014 
download | documentation | applications | faq | changelog | resources 


search for in the  


previousPacking basics
Tabular layout with GtkTablenext

Last updated: Sun, 12 May 2013
view this page in English

The most simple, but most often used containers are the GtkBoxes: GtkHBox and GtkVBox. They allow to add widgets in a single row, not more, and not less. GtkHBox arranges them horizontally, while GtkVBox lines them up vertically.

You add the widgets via pack_start() or pack_end() . pack_start() adds them one after the other from the beginning (left to right resp. top to bottom), while pack_end() adds them from the end on (right to left, or bottom to top).

You can influence the layout by adjusting the three optional parameters of pack_start() and pack_end() - see their documentation.

Example 7.1. Simple dynamic layout with GtkVBox

<?php
$w = new GtkWindow();
$w->set_title('GtkBox test');
$w->connect_simple('destroy', array('gtk', 'main_quit'));
 
$lbl = new GtkLabel('Your name:');
$scrwnd = new GtkScrolledWindow();
$txt = new GtkTextView();
$scrwnd->add($txt);
$btn = new GtkButton('Send');
 
$vbox = new GtkVBox();
$w->add($vbox);
 
$vbox->pack_start($lbl, false);
$vbox->pack_start($scrwnd, true, true);
$vbox->pack_start($btn, false);
 
$w->show_all();
Gtk::main();
?>

Start the demo and resize the window: The multiline text widget adjusts its size to fill all the space in the window which is not needed for the label or the button. Change the third parameter from true to false at the place where scrwnd is packed - what happens?

A special version of GtkBoxes are GtkHButtonBox and GtkVButtonBox: They behave same as their box counterparts, but can contain GtkButtons only. To compensate this limitation, they have some layout functions often needed for rows of buttons.


User Contributed Notes
tutorials.packing.box.php
add a note about notes
There are no user contributed notes for this page.


previousPacking basics
Tabular layout with GtkTablenext

Last updated: Sun, 12 May 2013
view this page in English


credits 

PHP  Copyright © 2001-2014 The PHP Group
 All rights reserved.
Last updated: Sun May 12 20:51:01 2013 CEST