PHP-GTK
Monday, November 24, 2014 
download | documentation | applications | faq | changelog | resources 


search for in the  


previousGtkTreeStore
GtkTreeStore::appendnext

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

GtkTreeStore Constructor

GtkTreeStore (GtkType type_column_0 [, GtkType type_column_1 [, GtkType type_column_2, ...]]);

Create a new tree store with a number of columns. For each colum, the type has to be specified by choosing one of the GtkTypes.

Example 130. Creating and filling a GtkTreeStore

<?php
/*
* GtkTreeStore example: Regions and the population
*  of some european states
* Create a tree store with string and long columns
*/
$store = new GtkTreeStore(Gtk::TYPE_STRING, Gtk::TYPE_LONG);
 
//append a row to the root (NULL for parent)
$nothern = $store->append(null, array('Northern europe', 0));
$western = $store->append(null, array('Western europe', 0));
$central = $store->append(null, array('Central europe', 0));
 
//append a row as a child to another row: $central as parent
$store->append($central, array('Germany', 83251851));
//$western as parent
$store->append($western, array('France', 59765983));
$store->append($western, array('Netherlands', 16318199));
$store->append($nothern, array('Norway', 4525116));
 
 
//display it
$wnd = new GtkWindow();
$wnd->set_title('GtkTreeStore example');
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));
 
//create the view with the tree store set as model
$view = new GtkTreeView($store);
 
//cell renderer, which actually displays the text
$cell_renderer = new GtkCellRendererText();
//append one column to the view which displays the tree store column 0
$view->append_column(new GtkTreeViewColumn('Country', $cell_renderer, 'text', 0));
//display column 1 from the tree store
$view->append_column(new GtkTreeViewColumn('Population', $cell_renderer, 'text', 1));
//show all children at once
$view->expand_all();
 
$wnd->add($view);
$wnd->show_all();
Gtk::main();
?>

User Contributed Notes
gtk.gtktreestore.constructor.php
add a note about notes
There are no user contributed notes for this page.


previousGtkTreeStore
GtkTreeStore::appendnext

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