Re: [PHP-GTK] Getting text from gtk_entry
[email protected] ("Steph")
| Newsgroups | php.gtk |
|---|---|
| Message-ID | <010b01c11bcc$829a1960$ac61073e@t2r1o8> |
Loll - like this. You pass the function your data as its parameters. Basically. (note that between the err msgs you now get the username echoed as required). ps are you behind a firewall or something? your smtp definitely hates mine. Stezzzzzzzzzzzzzzzzz ----- Original Message ----- From: "Lorrie Cooke" <[email protected]> To: <[email protected]> Sent: Friday, August 03, 2001 4:09 AM Subject: [PHP-GTK] Getting text from gtk_entry 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"; } -------------------------------------------------------------------------------- <? dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')) || die("Can't load php_gtk module!\n"); function write_preferences(){ global $username; $user = $username->get_text(); echo "$user:$username"; } //=============================================================== //prefereces window //=============================================================== function pref_window() { global $username,$password,$host; $query = &new GtkDialog(); $query->set_title('Preferences'); $query->set_default_size(150, 250); $label = &new GtkLabel('Username:'); $vbox = $query->vbox; $vbox->pack_start($label, TRUE, TRUE, 0); $label->show(); $username = &new GtkEntry(); $vbox = $query->vbox; $vbox->pack_start($username, TRUE, TRUE, 0); $username->show(); $label = &new GtkLabel('Password:'); $vbox = $query->vbox; $vbox->pack_start($label, TRUE, TRUE, 0); $label->show(); $password = &new GtkEntry(); $vbox = $query->vbox; $vbox->pack_start($password, TRUE, TRUE, 0); $password->show(); $label = &new GtkLabel('Host:'); $vbox = $query->vbox; $vbox->pack_start($label, TRUE, TRUE, 0); $label->show(); $host = &new GtkEntry(); $vbox = $query->vbox; $vbox->pack_start($host, TRUE, TRUE, 0); $host->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(); } //=============================================================== //Main Window //=============================================================== function missioncontrol() { $window = &new GtkWindow(); $window->set_title("MySQL Administration 0.0.1"); $window->set_default_size(450, 25); $window->set_uposition(0, 0); $window->connect('delete_event', create_function('', 'gtk::main_quit();')); $box = &new GtkVBox(); $window->add($box); $box->show(); $vbox = &new GtkVBox(); $box->pack_start($vbox,false,false); $vbox->show(); $vbox->set_border_width(3); $hbox = &new GtkHBox(); $vbox->pack_start($hbox,false,false); $hbox->show(); $button = &new GtkButton('Connect'); $button->connect('clicked',write_preferences); $hbox->pack_start($button); $button->show(); $button = &new GtkButton('Preferences'); $button->connect('clicked',pref_window); $hbox->pack_start($button); $button->show(); $button = &new GtkButton('Quit'); $button->connect('clicked',create_function('', 'gtk::main_quit();')); $hbox->pack_start($button); $button->show(); $window->show_all(); } missioncontrol(); Gtk::main(); ?> -------------------------------------------------------------------------------- -- PHP GTK Mailing List (http://www.php.net/) To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] To contact the list administrators, e-mail: [email protected]