Can't add new widget to GtkFixed inside class
| From: | gell6 | Date: | Sat, 08 Apr 2006 10:53:06 +0000 |
| Subject: | Can't add new widget to GtkFixed inside class | ||
| Groups: | php.gtk.dev | ||
| Request: | Send a blank email to php-gtk-dev+get-2720@lists.php.net to get a copy of this message | ||
Hi
I'm trying to add buttons to GtkFixed in realtime using a class method.
The code I'm posting is greatly simplified to isolate the problem. Basically
the ButtonClass class just makes a new button and uses put() to put the
button inside a GtkFixed, which is defined outside the class, in the main
body of the file.
Now, when $button1 is clicked it should invoke the class and make a new
button. It doesn't.
However, when I add the line
MakeNewButton($fixed);
to the main body of the code, it invokes the class and makes the buttton ok!
Why doesn't the class work when called by connect_simple?
Here's the code:
<?php
if (!class_exists('gtk')) { // standard gtk stuff
die("Please load the php-gtk2 module in your php.ini\r\n");
}
$wnd = new GtkWindow();
$wnd->set_title('MyApp');
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));
$fixed = new GtkFixed ();
$button1 = new GtkButton("Button 1");
$fixed->put($button1, 10, 10);
$button1 -> connect_simple ("clicked", "MakeNewButton", $fixed);
$wnd->add($fixed); $wnd->show_all();
Gtk::main();
function MakeNewButton ($fixed) {
$a = new ButtonClass;
$a -> DoStuff ($fixed);
}
// --- class code ----
class ButtonClass {
function DoStuff ($fixed) {
$button2 = new GtkButton("Button 2");
$fixed->put($button2, 30, 40);
}
}
?>
Thanks!
--
View this message in context: http://www.nabble.com/Can%27t-add-new-widget-to-GtkFixed-inside-class-t1416282.html#a3817074
Sent from the Php - GTK - Dev forum at Nabble.com.