Problem with GTk entry
| From: | difenza2003\@libero\.it | Date: | Mon, 09 Aug 2004 12:19:27 +0000 |
| Subject: | Problem with GTk entry | ||
| Groups: | php.gtk.general | ||
| Request: | Send a blank email to php-gtk-general+get-4946@lists.php.net to get a copy of this message | ||
I want return a string value from a GTkEntry when clicked a button to insert into GTkTExt but i try
and receive this error:
Fatal error: Call to a member function on a non-object.
I write this code:
<?php
//gtk.php
if(!extension_loaded("gtk")) {
dl("php_gtk." . PHP_SHLIB_SUFFIX);
}
function shutdown() {
echo "Shutting down now...";
gtk::main_quit();
}
function return_text() {
global $input;
$str = $input->get_text();
$str_tag = "<b>" . $str . "</b>";
if (!$str)
return false;
else
return $str;
}
function Bold() {
global $editor, $input;
$str = return_text();
$editor->insert(NULL,NULL,NULL,$str);
$window = &new GtkWindow();
$box = &new GtkHBox();
$input = &new GtkEntry();
$input->set_text("Insert the string to format");
$button = &new GtkButton('Inserisci');
$button->connect('clicked','return_text');
$box->pack_start($input);
$box->pack_start($button);
$window->add($box);
$window->connect('destroy','shutdown');
$window->show_all();
}
$window2 = &new GtkWindow();
$window2->set_title("Editor");
$box = &new GtkHbox();
$editor = &new GtkText();
$editor->set_editable(1);
$adj = $editor->vadj;
$scroll = &new GtkVScrollbar($adj);
$box->pack_start($editor);
$box->pack_start($scroll);
$window2->add($box);
$window2->show_all();
//pannello di controllo con pulsanti per formattare
$window = &new GTkWindow();
$window->set_title("::[ Felix ]::");
$window->connect('destroy','shutdown');
$control = &new GTkVButtonBox();
$window->add($control);
$button_1 = &new GtkButton("Bold");
$button_2 = &new GtkButton("Break");
$button_3 = &new GtkButton("Italic");
$button_4 = &new GtkButton("List");
$button_1->connect("clicked","Bold");
$control->pack_start($button_1);
$control->pack_start($button_2);
$control->pack_start($button_3);
$control->pack_start($button_4);
$window->show_all();
gtk::main();
?>