Author Topic: PHP GTK2  (Read 622 times)

0 Members and 1 Guest are viewing this topic.

Offline AlexTopic starter

  • Global Moderator
  • Addict
  • *
  • Posts: 2,487
  • Gender: Male
  • < 1 billion
    • View Profile
PHP GTK2
« on: January 31, 2010, 08:59:33 PM »
I've never used PHP GTK2, or PHP GTK1 for that matter, so I decided to mess around it with. Using the documentation it seems pretty straightforward, but I have hit a snag.

I'm using the GtkNotebook object and for one of its pages I've added a GtkVBox object. Like so:

$this->main_list = new GtkVBox();
$this->book->append_page(
	
$this->main_list,
	
new 
GtkLabel('Main List')
);


I then create a timer to run a function every 15 seconds (for example) and then call the function once at start-up as well.

Gtk::timeout_add(1000 15, array($this'update'));
$this->update();


The setup of the update method is basically like this:

public function update()
{
	
// Attemping to remove all children from $this->main_list, if there are any
	
foreach(
$this->main_list->get_children() as $child)
	
{
	
	
$this->main_list->remove($child);
	
}
	
foreach(...) 
// Some complex loops
	
{
	
	
// Construct a new GtkTable object ($table)
	
	
// Add $table to $this->main_list
	
	
$this->main_list->pack_start($tablefalsefalse10);
	
}
	
return 
true// otherwise the timer dies
}


Now, the first call to $this->update() works as expected and populates $this->main_list (on the GtkNotebook page) with the expected. However when it's called a second time by the timer instead of clearing all the children from the GtkNotebook page and populating it with the new newly constructed GtkTable objects the page is just cleared and nothing new is displayed.

I've done all the debugging to make sure loops were producing the expected outputs and whatnot, so I figure it must be something simple I'm missing.

Any ideas?
:anim_rules: Read the rules, :rtfm: and don't forget to use [code] / [php] tags!