Re: Why doesn't this work? Driving me crazzzzzy
| From: | Jake Gordon | Date: | Wed, 06 Jul 2005 17:53:06 +0000 |
| Subject: | Re: Why doesn't this work? Driving me crazzzzzy | ||
| References: | 1 2 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-5912@lists.php.net to get a copy of this message | ||
Hi,
Thanks Nathan.
I solved the problem. All I had to do was remove the & from &new ...
As per why not use set_text, this is because I'm using the labels as placeholders just to get the general method working for now. Instead of labels there'll be tabbed pages, tables etc. when I'm done.
Jake
Malk0 wrote:
hi, this is not an answer to you rquestion at all but why don't you simply use the gtklabel::set_text method to do this? can regarding your problem, I'm not sure cause i haven't test it (not enough time :-/) but i think this should work : function change_main($button, $section) { global $layout, $main; // First destroy what was here before, if anything if(is_a($main,'gtklabel')) $main->destroy(); $main = &new GtkLabel($section); $layout->put($main,100,40); $main->show(); } nathan 2005/7/6, Jake Gordon <php-gtk@jakeg.co.uk>:I've never really used much OO programming before, so I expect the answer to this is really easy, but I've lost most my hair now having been trying to figure out where the hell I'm going wrong for the last 3 hours. The code is meant to change the contents of a part of the layout by destroying the object $main if it already exists, and then creating a new object with the same name and putting it in the same place. I call it using: $button->connect('clicked', 'change_main', $section); The function is: function change_main($button, $section, $main) {global $layout, $main;// First destroy what was here before, if anything if($main) $main->destroy();$main = &new GtkLabel($section); $layout->put($main,100,40); $main->show();} If I call the function like this instead: $main = change_main(null, "splash", $main); ... with 'return $main' at the bottom of the function, it works. But how can I do this without returning $main seeing as ->connect doesn't allow this, no? I don't know where to look for an answer. I don't know where to begin. Its driving me insane! The problem is that $main doesn't exist within the function. Even though I've declared it as global in scope. Is this becuase you can't make an object global? So then how the hell can I do it???? HELP!!!!!!!!!!!!!!!!!!!! Jake. -- PHP-GTK General Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php