PHP-GTK
Thursday, August 21, 2014 
download | documentation | applications | faq | changelog | resources 


search for in the  


previousGtkListStore
GtkListStore::appendnext

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

GtkListStore Constructor

GtkListStore ( GType type_column_0 [, GType type_column_1 [, GType type_column_2 , ...]]);

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

Example 94. Creating and filling a GtkListStore

<?php
/*  GtkListStore example
 Here we create a list of the largest cities.
 For that we need a list store with two columns:
 The name and the number of inhabitants.
 The "name" is of type "string", and the number
 of inhabitants is of type long (big integer).
*/
$store = new GtkListStore(Gobject::TYPE_STRING, Gobject::TYPE_LONG);
 
/*
* Using the "set" method
*/
 
//at first, get an iterator for a new row
$iterator = $store->append();
//now use that to set the name at that row (column 0)
$store->set($iterator, 0, 'Tokio');
//same row: set the inhabitants into column 1
$store->set($iterator, 1, 34100000);
 
//You can set a whole row at once:
$iterator = $store->append();
//we add the data "Mexico city" at column 0 and 
// "22 million" at column 1 at the row $iterator
$store->set($iterator, 0, 'Mexico city', 1, 22650000);
 
//Or, even faster: don't even create an iterator variable
$store->set($store->append(), 0, 'Seoul', 1, 22250000);
 
 
/*
* Using "append" to add a row without an iterator
*/
$store->append(array('New York', 21850000));
$store->append(array('São Paulo', 20200000));
 
 
/*
* And now show what we've got in the store
*/
function echoRow($store, $path, $iter)
{
    $city   = $store->get_value($iter, 0);
    $number = $store->get_value($iter, 1);
    echo $city . ' has ' . $number . " inhabitants.\r\n";
}
$store->foreach('echoRow');
?>

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


previousGtkListStore
GtkListStore::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:50:59 2013 CEST