php-gtk win crashes
[email protected] ("Hien Quan") Mon, 6 Aug 2001 14:25:14 +0100
| Newsgroups | php.gtk |
|---|---|
| Message-ID | <001c01c11e7b$3a921f30$861f0263@icbecuk> |
Hi All,
From various code snippets posted to this group and the example files, I'm
trying to run the program below, but keep getting a Dr. Watson php.exe crash
dump on WinNT.
The window opens up OK with the default NULL value in the entry box. However
php crashes when the timeout_add(...) routine is called for the second time.
Any thoughts?
Thanks,
Hien
----code snippet----
<?
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
dl('php_gtk.dll');
else
dl('php_gtk.so');
function delete_event() {
return false;
}
/*
* Called when the window is being destroyed. Simply quit the main loop.
*/
function destroy() {
Gtk::main_quit();
}
// general close window function all widgets
function close_window($widget,$text_entry)
{
$value = $text_entry->get_text();
print $value;
$window = $widget->get_toplevel();
$window->hide();
return true;
}
function create_entry()
{
$window = &new GtkWindow;
$windows['entry'] = $window;
$window->connect('delete-event', 'delete_event');
$window->set_title('Configuration');
$window->set_border_width(0);
$box1 = &new GtkVBox();
$window->add($box1);
$box1->show();
$box2 = &new GtkVBox(false, 10);
$box2->set_border_width(10);
$box1->pack_start($box2);
$box2->show();
$entry = &new GtkEntry();
$entry->set_text('Hello World');
$entry->select_region(0, 5);
$box2->pack_start($entry);
$entry->show();
$entry->set_visibility(false);
$separator = &new GtkHSeparator();
$box1->pack_start($separator, false);
$separator->show();
$box2 = &new GtkVBox(false, 10);
$box2->set_border_width(10);
$box1->pack_start($box2, false);
$box2->show();
$button = &new GtkButton(' Save and Close');
$button->connect('clicked', 'close_window',$entry);
$button->set_flags(GTK_CAN_DEFAULT);
$button->grab_default();
$button->show();
}
function draw_screen(){
global $entry1,$timer;
$entry1->set_text("".$timer++);
return true;
}
// create_main_window()
$window = &new GtkWindow();
$window->set_policy(false, false, false);
$window->set_name('main window');
$window->set_usize(200, 400);
$window->set_uposition(20, 20);
$window->connect_object('destroy', array('gtk', 'main_quit'));
$window->connect_object('delete-event', array('gtk', 'false'));
$box1 = &new GtkVBox();
$window->add($box1);
$label = &new GtkLabel('Timer');
$box1->pack_start($label,false);
$label->show();
$entry1 = &new GtkEntry();
$entry1->set_text('NULL');
$box1->pack_start($entry1,false);
$entry1->show();
$entry1->set_editable(false);
$entry1->set_sensitive(true);
$separator = &new GtkHSeparator();
$box1->pack_start($separator, false);
$box2 = &new GtkVBox(false, 10);
$box2->set_border_width(10);
$box1->pack_start($box2, false);
$button = &new GtkButton('close');
$button->connect_object('clicked', array('gtk', 'main_quit'));
$box2->pack_start($button);
$button->set_flags(GTK_CAN_DEFAULT);
$button->grab_default();
$window->show_all();
//******* Global variables
$timer = 0;
//create_main_window();
gtk::timeout_add(1500, 'draw_screen');
Gtk::main();
?>