<?php if (!extension_loaded('gtk')) { dl('php_gtk.' . PHP_SHLIB_SUFFIX); } gtk::timeout_add(1, "callback", "some data"); echo "callback added\n"; gtk::main(); function callback($data) { static $i = 0; if ($i < 1000) { $i++; echo "callback called\n"; return TRUE; } else { echo "callback finished, data was: {$data}\n"; gtk::main_quit(); } }
/** * Begin scrolling the text from the current character position. * Work horse for startScroll. Usually connected to an event. * * unPause() does pretty much the same thing as startScroll * except that it does not manipulate the current character * position. When you unpause the scroll, the text continues * from where it left off when it was paused. * * This method is best used when conneted to an event. * * @access public * @param none * @return boolean true if the scrolling has started. * @see setUnPauseSignal */ function unPause() { // Pretty much just like start but without resetting the postion. // First check to see if there is a timeout already started. if (isset($this->gtkTimeoutTag)) { // Throw error about scroll already started. $this->_error('Cannot unpause. Text not scrolling.', GTK_SCROLLINGLABEL_DEFAULT_ERROR, PEAR_ERROR_PRINT); return false; } elseif (!isset($this->speed)) { // Throw error about no value for speed. return $this->_error('Cannot unpause. No speed set.'); } else { // Start the scrolling. $this->gtkTimeoutTag =& gtk::timeout_add($this->speed, array(&$this, '_scrollLabel')); } // Give back the timeout tag. return $this->gtkTimeoutTag; }
<?php dl('php_gtk.so'); $window =& new GtkWindow(GTK_WINDOW_DIALOG); $window->set_title('Clock'); $window->set_border_width(10); $window->connect('destroy', 'destroy'); $label =& new GtkLabel(); $window->add($label); gtk::timeout_add(1000, 'update', $label); update($label); $window->show_all(); gtk::main(); function update($label) { $time = strftime('%H:%M:%S %p'); $label->set_text($time); return true; } function destroy($window) { gtk::main_quit(); }