Jump to content

Recommended Posts

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($table, false, false, 10);
}
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?

Link to comment
https://forums.phpfreaks.com/topic/190496-php-gtk2/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.