Re: php-gtk and globals

From: Date: Sun, 19 Jan 2003 13:07:35 +0000
Subject: Re: php-gtk and globals
References: 1 2  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-2926@lists.php.net to get a copy of this message
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ok, got working. For some reasons objects don't like to be globals, so I have to pass them as arguments. It's good to see that once you learned you can take a bit of time, but it's very easy to program in gtk-php. I've done in half hour a thing I made in 3 days last time, hehehehe :) On Sunday 19 January 2003 10:43, Steph wrote: > hrm > > make the entry global in the function where you make the connection, and > pass the entry as part of the 'clicked' signal. > > ----- Original Message ----- > From: "Iuri Fiedoruk" <iuri.f@terra.com.br> > To: <php-gtk-general@lists.php.net> > Sent: Sunday, January 19, 2003 12:29 PM > Subject: [PHP-GTK] php-gtk and globals > > > 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 - -- Iuri Fiedoruk Santa Maria, RS, Brasil -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE+KqMXZDi0YID7IhsRAhBJAJ4lDjFw30mLVvPcmx7DXA949kkPAgCffWmb Zu1mBaj5gpOgjwiSWrAu/AA= =lBJC -----END PGP SIGNATURE-----

« previous php.gtk.general (#2926) next »