Re: Why won't this work?

From: Date: Tue, 02 Jul 2002 04:22:08 +0000
Subject: Re: Why won't this work?
References: 1  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-2177@lists.php.net to get a copy of this message
the magic events_pendidng makes it sort of work.... The magical event_pending makes it work I think (- at least you get to see & use the alerts) function login($button,$entry_login_name,$entry_password,$entry_server){ $starttime = time(); $loop = 'GO'; while ( $loop == 'GO' ) { while (gtk::events_pending()) gtk::main_iteration(); $currenttime = time(); $currenttime = substr($currenttime,9,1); #print $currenttime; if ( $currenttime == 5 ){ /* while (gtk::events_pending()) gtk::main_iteration(); */ $name=$entry_login_name->get_text(); $passwd=$entry_password->get_text(); $server=$entry_server->get_text(); alert('Special Message For Your Eyes Only'); } while( $currenttime == 5 ){ /* while (gtk::events_pending()) gtk::main_iteration(); */ $currenttime = time(); $currenttime = substr($currenttime,9,1); } } } Regards, Simon Wheeler firepages. ----- Original Message ----- From: "james" <deadhead@cox.net> To: <php-gtk-general@lists.php.net> Sent: Tuesday, July 02, 2002 11:41 AM Subject: [PHP-GTK] Why won't this work? > This is just a proof of concept script that I've cobbled together from > examples I've looked at on the web (mostly the mysql query program). What I > want to do is have the user enter their login informations and click login. > After clicking login I want the program to enter a loop and display messages > (the alert function) when certain conditions are met (when time() has a 5 in > the 9th postion in this example). What happens is that after the first window > pops up you can't see $string or the button when the box comes up for the > alertt() function. If you wait a while, more boxes will pop up, but the same > thing happens, you can't see anything. If you click the X at the top right of > any alert window, Windows reports that the program is not responding. > > In case it's not appearant in my code here, I have no idea what I'm doing > with this stuff. This is my first time playing with GUI stuff. Thanks for any > guidance and help! > > James > > <?php > $std_title="MyFREEKINtest"; > > if (!class_exists('gtk')) { > if (strtoupper(substr(PHP_OS, 0,3) == 'WIN')) > dl('php_gtk.dll'); > else > dl('php_gtk.so'); > } > > function delete_event(){ > return false; > } > > function make_std_window($window_title,$frame_title){ > global $std_title; > $window= &new GtkWindow(); > $window->set_default_size(700,500); > $window->connect("destroy","close_window"); > $window->connect("delete_event","delete_event"); > $window->set_title($std_title." ".$window_title); > > $frame=&new GtkFrame($frame_title); > $window->add($frame); > $frame->show(); > > $vbox= &new GtkVBox(); > $vbox->set_homogeneous(false); > $frame->add($vbox); > $vbox->show(); > > return $window; > } > > function alert($string){ > global $std_title; > $string=wordwrap($string,70); > $dialog = &new GtkDialog(); > $dialog->set_policy(true, false, false); > $dialog->set_position(GTK_WIN_POS_CENTER); > file://$dialog->connect_object("destroy","close_window"); > $dialog->set_title($std_title." Display Message"); > > $dialog_vbox = $dialog->vbox; > $dialog_action_area = $dialog->action_area; > > $user_info_label = &new GtkLabel($string); > $dialog_vbox->pack_start($user_info_label); > > $ok_button = &new GtkButton("OK"); > $ok_button->connect("clicked","close_window"); > > $dialog_action_area->pack_start($ok_button); > > $dialog->show_all(); > } > > function close_window($widget){ > $window = $widget->get_toplevel(); > $window->hide(); > } > > function shutdown(){ > gtk::main_quit(); > } > > function do_login($button,$entry_login_name,$entry_password,$entry_server){ > $starttime = time(); > $loop = 'GO'; > while ( $loop == 'GO' ) { > $currenttime = time(); > $currenttime = substr($currenttime,9,1); > #print $currenttime; > > if ( $currenttim e == 5 > $name=$entry_login_name->get_text(); > $passwd=$entry_password->get_text(); > $server=$entry_server->get_text(); > alert('Special Message For Your Eyes Only'); > } > while( $currenttime == 5 ){ > $currenttime = time(); > $currenttime = substr($currenttime,9,1); > } > } > } > > /*create small login window*/ > $login_window=make_std_window("Login","Login"); > $login_window->connect('destroy','shutdown'); > $login_window->set_default_size(250,100); > $vbox=$login_window->child->child; > > /*top hbox*/ > > $hbox_top= &new GtkHBox(false,5); > $hbox_top->set_homogeneous(true); > $vbox->pack_start($hbox_top,false,false); > $hbox_top->show(); > > /*top label*/ > $label_top= &new GtkLabel("Login name:"); > $hbox_top->pack_start($label_top,false,false); > $label_top->show(); > > /*top textfield*/ > $entry_login_name=&new GtkEntry(); > file://$entry_login_name->set_text(""); > $hbox_top->pack_start($entry_login_name,false,false); > $entry_login_name->show(); > > /*middle box*/ > $hbox_middle=&new GtkHBox(false,5); > $hbox_middle->set_homogeneous(true); > $vbox->pack_start($hbox_middle,false,false); > $hbox_middle->show(); > > /*middle label*/ > $label_middle= &new GtkLabel("Password:"); > $hbox_middle->pack_start($label_middle,false,false); > $label_middle->show(); > > /*middle textfield*/ > $entry_password=&new GtkEntry(); > file://$entry_password->set_text(''); > $entry_password->set_visibility(false); > $hbox_middle->pack_start($entry_password,false,false); > $entry_password->show(); > > /*middle box 2 (added later)*/ > $hbox_middle2=&new GtkHBox(false,5); > $hbox_middle2->set_homogeneous(true); > $vbox->pack_start($hbox_middle2,false,false); > $hbox_middle2->show(); > > /*middle label*/ > $label_middle2= &new GtkLabel("Server:"); > $hbox_middle2->pack_start($label_middle2,false,false); > $label_middle2->show(); > > /*middle textfield*/ > $entry_server=&new GtkEntry(); > file://$entry_server->set_text(""); > $hbox_middle2->pack_start($entry_server,false,false); > $entry_server->show(); > > /*bottom box*/ > $hbox_bottom=&new GtkHBox(false,5); > $hbox_bottom->set_homogeneous(true); > $vbox->pack_start($hbox_bottom,false,false); > $hbox_bottom->show(); > > > /*login button*/ > $login_button = &new GtkButton("Login"); > $login_button->connect("clicked","do_login",$entry_login_name,$entry_passwor d > ,$entry_server); > $hbox_bottom->pack_start($login_button,false,false,15); > > $login_window->show_all(); > > gtk::main(); > ?> > > -- > PHP-GTK General Mailing List (http://gtk.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > >

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