Re: gtk::timeout_add Help please !

From: Date: Mon, 26 Jan 2004 04:05:40 +0000
Subject: Re: gtk::timeout_add Help please !
References: 1  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-4368@lists.php.net to get a copy of this message
Hi, Monday, January 26, 2004, 5:53:30 AM, you wrote: JG> Hi to all JG> I am trying to execute a function multiple time and display JG> the number of time the function had executed in a label. The JG> problem I am having is the code execute once and quite, I tried JG> different things suggested on the archive mailing list with not JG> success. Could somebody help me figure this out please!!. Try this: <?php if (!extension_loaded('gtk')) { dl( 'php_gtk.' . PHP_SHLIB_SUFFIX); } function test() { static $x = 0; $x = $x + 1; $GLOBALS['label']->set_text($x); return true; } function delete_event() { return false; } function destroy() { Gtk::main_quit(); } $window = &new GtkWindow(); $window->connect('destroy', 'destroy'); $window->connect('delete-event', 'delete_event'); $window->set_border_width(10); $window->set_usize(300, 300); $window->set_title('Web Upload'); $frame = &new GtkFrame('Counter'); $window->add($frame); $frame->show(); $box1 = &new GtkVBox(); $frame->add($box1); $box1->show(); $label = &new GtkLabel(); $box1->pack_start($label); $label->show(); $separator = &new GtkHSeparator(); $box1->pack_start($separator); $separator->show(); $box2 = &new GtkHButtonBox(); $box2->set_layout(GTK_BUTTONBOX_SPREAD); $box1->add($box2); $box1->show(); $button = &new GtkButton('Exit'); $button->connect('clicked', 'destroy'); $box2->pack_start($button); $label->set_text($x); /* * Show the window and all its child widgets. */ $window->show_all(); gtk::timeout_add(2000,'test'); /* Run the main loop. */ Gtk::main(); ?> -- regards, Tom

« previous php.gtk.general (#4368) next »