note 118 added to gtk.gtkcombo.constructor.php

From: Date: Sat, 23 Mar 2002 12:10:14 +0000
Subject: note 118 added to gtk.gtkcombo.constructor.php
Groups: php.gtk.webmaster 
Request: Send a blank email to php-gtk-webmaster+get-314@lists.php.net to get a copy of this message
A quick and dirty function to populate the contents of a combo box with the key/value pairs in an array. Modify for your use function populate_ind_combo($combo, $array){ $list = $combo->list; $keys = array_keys($array); print_r($keys); for ($i=0;$i<count($array);$i++){ $item = &new GtkListItem(); $label = &new GtkLabel($array[$keys[$i]]); $item->add($label); $data = $keys[$i]; $item->set_data($i, $data); $list->add($item); $item->show_all(); } // here you will need to connect signals if required } pass the function the combo object and an array. http://gtk.php.net/manual/en/gtk.gtkcombo.constructor.php

« previous php.gtk.webmaster (#314) next »