question about label adjustment
| From: | jack | Date: | Mon, 24 Nov 2003 14:59:39 +0000 |
| Subject: | question about label adjustment | ||
| Groups: | php.gtk.general | ||
| Request: | Send a blank email to php-gtk-general+get-4227@lists.php.net to get a copy of this message | ||
Hi all,
I have a small program as following. Just wonder why the label adjustment
doesn't work at all. After run it the label adjustment is still CENTER. Is
there anything wrong? And when a user selects a item on the list and click
the button, how do I display the selected item on the label.
<?php
if (!extension_loaded('gtk')) {
dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);
}
function delete_event(){
return false;
}
function onClicked(){
global $label;
$ar=$list->selection;
$s1=$ar[0];
$label->set_text($s1); /*won't work*/
}
$but = &new GtkButton("show selected");
$but->connect('clicked','OnClicked');
$label = &new GtkLabel();
$label->set_text("Whatever text you wish to pass");
$label->set_line_wrap(true);
$label->set_justify(GTK_JUSTIFY_LEFT);
$list = &new GtkList();
$list->set_selection_mode(GTK_SELECTION_BROWSE);
foreach (range(1, 12) as $j1)
$ar[] = &new GtkListItem(strftime('%B', mktime(0, 0, 0, $j1)));
$list->append_items($ar);
$swin = &new GtkScrolledWindow();
$swin->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
$swin->add_with_viewport($list);
$box = &new GtkVBox(false, 10);
$box->set_border_width(10);
$box->pack_start($label);
$box->pack_start($swin);
$box->pack_start($but, false);
$win = &new GtkWindow();
$win->connect_object('destroy', array('gtk', 'main_quit'));
$win->connect('delete-event', 'delete_event');
$win->set_title('PHP Rules!');
$win->set_name('MainWindow');
$win->set_usize(150, 200);
$win->add($box);
$win->show_all();
Gtk::main();
?>