Getting text from gtk_entry
| From: | Lorrie Cooke | Date: | Fri, 03 Aug 2001 03:09:11 +0000 |
| Subject: | Getting text from gtk_entry | ||
| Groups: | php.gtk | ||
| Request: | Send a blank email to php-gtk+get-2480@lists.php.net to get a copy of this message | ||
Hi :)
Im a bit confused on how i get text out of a entry field
I have two functions the first opens a "preference" window.. which has
the entry boxes
On pressing OK runs another function... however, im not sure how to get
the value of the entry box out of one function and into another... i
have globalized the variable however when i try using the method:
$user = $username->get_text();
in the second function, it errors with the error: call to member
function on a non - object...
So my question is how do i get the value of $username->get_text from one
function to another?
Thanks for your help! :)
Loll
//=======================================================
below is a snippet and atached is the full script thus far :)
function pref_window() {
global $username,$password,$host;
$query = &new GtkDialog();
$query->set_title('Preferences');
$query->set_default_size(150, 250);
$username = &new GtkEntry();
$vbox = $query->vbox;
$vbox->pack_start($username, TRUE, TRUE, 0);
$username->show();
$okbutton = &new GtkButton('Save Settings');
$okbutton->connect('clicked', write_preferences);
$okbutton->connect_object('clicked', array($query, 'destroy'));
$query->connect('delete_event', create_function('',
'gtk::main_quit();'));
$action_area = $query->action_area;
$action_area->pack_start($okbutton, TRUE, TRUE, 0);
$okbutton->show();
$query->show_all();
}
function write_preferences(){
global $username;
$user = $username->get_text();
echo "$user:$username";
}