php-gtk and globals
| From: | Iuri Fiedoruk | Date: | Sun, 19 Jan 2003 12:29:03 +0000 |
| Subject: | php-gtk and globals | ||
| Groups: | php.gtk.general | ||
| Request: | Send a blank email to php-gtk-general+get-2924@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I'm restarting (again) to program with php-gtk and I have some small doubts.
I have two functions here, one that draws a login screen (pretty simple) and
another that should test the login.
The thing I want to know is how to make my test_login() function to "see" the
value on the entry when I press the login button. I've tryied to make
$login_input (the entry) global, but this didn't worked.
So I assume I have to pass the value as argument in the $button->connect(),
right?
// função que testa o login
function test_login() {
// global $login_window;
global $login_input;
$login = $login_input->get_text();
echo "Login: $login\n";
}
// create and shows a login screen
function draw_login() {
global $login_window;
// cria janela
$login_window = &new GtkWindow();
$login_window->connect('destroy', 'destroy');
$login_window->connect('delete-event', 'delete_event');
$login_window->set_border_width(10);
// cria box vertical apra conter items
$v_box1 = &new GtkVBox(false, 10);
// adiciona caixa vertical na janela
$login_window->add($v_box1);
// cria caixa horizonal para texto do login e input do login
$h_box1 = &new GtkHBox(false, 10);
// coloca caixa horizontal na caixa vertical
$v_box1->add($h_box1);
// cria texto de login
$login_text = &new GtkLabel('Login: ');
// cria input de login
$login_input = &new GtkEntry();
// coloca texto e input de login na caixa horizontal
$h_box1->add($login_text);
$h_box1->add($login_input);
// cria botão de login
$button = &new GtkButton('login');
// conecta o botão a uma função que testa o login
$button->connect('clicked', 'test_login');
// coloca botão na caixa vertical
$v_box1->add($button);
// mostra janela e seus widgets
$login_window->show_all();
}
- --
Iuri Fiedoruk
Santa Maria, RS, Brasil
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE+KpoSZDi0YID7IhsRAgoAAJ9uFFUzBfKS1cpB0MjZA9NMzbMETgCdHj1S
u00jHcHbjVCcoH2pDouQqEc=
=rpfj
-----END PGP SIGNATURE-----