Re: Help with Dialog/Popup

From: Date: Thu, 04 Aug 2005 08:48:07 +0000
Subject: Re: Help with Dialog/Popup
References: 1 2 3 4  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-6158@lists.php.net to get a copy of this message
Hi, again, I've used this code to show a window while my little app is autoupdating from the server web ... (sorry it's in italian) and it works as i want ...m i don't know if can be usefull but ... take a look ... Eplanation: call to a function "auto_update" ... the function display a window and create a call to another function after 10 msec. so the interface will be updated before this call ... Problems: During the execution of the second call, the interface, won't listen any event ... because phpgtk is NOT real multithread ... :-( function auto_update(){ global $windows; echo "Ricerca nuove versioni del software ...\n"; $winSrcNewVers = array(); $windows['winSrcNewVers']=&New GtkWindow(); $windows['winSrcNewVers']->connect('destroy', 'delete_event'); $windows['winSrcNewVers']->set_modal(true); $winSrcNewVers['label0'] = &new GtkLabel("Attendere prego"); $winSrcNewVers['label1'] = &new GtkLabel("Ricerca nuove versioni del software in corso ..."); $vbox = &new GtkVBox(); $vbox->pack_start($winSrcNewVers['label0'], true, false); $vbox->pack_start($winSrcNewVers['label1'], true, false); $windows['winSrcNewVers']->add($vbox); $windows['winSrcNewVers']->set_position(GTK_WIN_POS_CENTER); $windows['winSrcNewVers']->set_default_size(300,80); $windows['winSrcNewVers']->set_title(APP_NAME." AutoUpdate"); $windows["winSrcNewVers"]->show_all(); gtk::timeout_add(10, 'cerca_nuove_versioni'); } function cerca_nuove_versioni(){ global $windows, $myHttpreader, $SystemRoot; prepare_url(); $myHttpreader->query .= "&do=AGGIORNA"; $myHttpreader->ReadUrl(); if($myHttpreader->err!="") MsgBox($myHttpreader->err,"Attenzione",MB_ICONWARNING); else{ $serverErr = parsexml("ERR",$myHttpreader->httpresult); if(strstr($serverErr,"ERRORE:")) MsgBox($serverErr,"Attenzione",MB_ICONWARNING); else{ $updates = parsexml("UPDATE",$myHttpreader->httpresult); if($updates!=''){ $newfiles = stripfromtextarray($updates,"<FILE>","</FILE>"); if(count($newfiles)>0){
    $newbuild = stripfromtext($updates,"<BUILD>","</BUILD>");
    echo "\nBUILD $newbuild ...\nUPDATE di ".count($newfiles)." files ...\n";
    foreach ($newfiles as $file) {
     $name = stripfromtext($file,"<NAME>","</NAME>");
     $name = str_replace("%AppPath%",PWD,$name);
     $name = str_replace("%SystemRoot%",$SystemRoot,$name);
     $name = str_replace((OS=='WIN'?"/":"\\"),BAR,$name);
     echo "Installing: ".$name." ...";
     $content = stripfromtext($file,"<CONTENT>","</CONTENT>");
     FileWrite($name,base64_decode($content));
     echo "ok\n";
    }
    echo "Aggiornamento completato.\nRiavviare il software\n";
    MsgBox("Aggiornamento completato\nRiavviare il software",APP_NAME,MB_ICONEXCLAMATION);
} }else MsgBox("Nessun aggiornamento disponibile",APP_NAME,MB_ICONEXCLAMATION); } } $windows["winSrcNewVers"]->hide_all(); } I hope it will help ... bye Simone ----- Original Message ----- From: "Simone Cosci" <simone@interworld.it> To: <php-gtk-general@lists.php.net> Sent: Thursday, August 04, 2005 9:47 AM Subject: Re: [PHP-GTK] Help with Dialog/Popup
Hi, in my opinion the best way is this ... $popup = new GtkWindow(GTK_WINDOW_DIALOG); $label = new GtkLabel("Message goes here"); $label->show(); $popup->set_usize(300,150); $popup->set_position(GTK_WIN_POS_CENTER); $popup->add($label); $popup->show_all(); $delay = 5; // Secons of delay $callback_after_delay = "hide_popup"; function hide_popup(){ global $popup; $popup->destroy(); } gtk::timeout_add($delay,$callback_after_delay); gtk::main(); Bye S. ----- Original Message ----- From: "Neil Eisgruber" <neisgruber@sunblocksystems.com> To: "Christian Weiske" <cweiske@cweiske.de> Cc: <php-gtk-general@lists.php.net> Sent: Wednesday, August 03, 2005 8:16 PM Subject: Re: [PHP-GTK] Help with Dialog/Popup
Thanks Christian, that got me a bit further. Here is what is going on now. I have the following code: $popup = new GtkWindow(GTK_WINDOW_DIALOG); $label = new GtkLabel("Message goes here"); $label->show(); $popup->set_usize(300,150); $popup->set_position(GTK_WIN_POS_CENTER); $popup->add($label); $popup->show_all(); while(gtk::events_pending()) gtk::main_iteration(); sleep(5); //this will be replaced with the function that does the real work $popup->destroy(); Now the window appears for the 5 seconds, but the label is never drawn within it. I'm also not sure if this is the proper usage of gtk::events_pending() as the documentation confused me a bit... Thanks, Neil Quoting Christian Weiske <cweiske@cweiske.de>:
Hello Neil,
dialog box disappear when the function is done. Currently, not matter what
I
do, the dialog box does not appear until after the action is complete and
is
destroyed immediately. Is there any way I can accomplish this kind of functionallity with php-gtk?
You don't give the system enough time to display. Search for gtk::events_pending in the wiki or the docs. Regards/MfG, Christian Weiske -- XMMS is playing now:
-- PHP-GTK General Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- PHP-GTK General Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


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