<?php
require_once 'Gtk2/IndexedComboBox.php';
// このデータを表示します
$arData = array(
1 => 'Germany',
2 => 'United Kingdom',
3 => 'Spain',
4 => 'France'
);
// コンボを作成し、配列を設定します
$combo = new Gtk2_IndexedComboBox();
$combo->set_array($arData);
// 二番の要素をアクティブにします
$combo->set_active_key(2);
// 変更を追いかけます
$combo->connect('changed', 'comboChanged', $lbl);
function comboChanged($combo, $lbl)
{
$lbl->set_text(
"コンボが変更されました:\r\n"
. 'キー: ' . $combo->get_active_key() . "\r\n"
. '値: ' . $combo->get_active_text()
);
}
// 変更を表示するラベル
$lbl = new GtkLabel("状態\r\n\r\n");
// 標準の手順
$vbox = new GtkVBox();
$vbox->pack_start($combo);
$vbox->pack_start($lbl);
$wnd = new GtkWindow();
$wnd->connect_simple('destroy', array('Gtk', 'main_quit'));
$wnd->add($vbox);
$wnd->show_all();
Gtk::main();
?>
|