Re: GtkProgressBar Example

From: Date: Tue, 28 Mar 2006 15:06:49 +0000
Subject: Re: GtkProgressBar Example
References: 1 2  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-6824@lists.php.net to get a copy of this message
Hi, Thank you for the reply. I sincerely apology if the tone of my question seems offensive or "a bit harsh". I can assure you it was never intended to come across that way. I was simply asking for help. I am very new to PHP programming and GTK2. I am having fun with PHP-GTK2 and hope it continues to GROW. I really appreciate all the work you guys are doing to bring this development platform to us. The coding example you provided helped a lot. Also the Gtk2_PHPConfig was of great help. The key for me in getting the ProgressBar to update and display correctly was the following code. while (Gtk::events_pending()) { Gtk::main_iteration(); } along with the hint for the following coding line. $y->set_fraction((float)($i/100.0)); The code I copied from the manual must be for GTK1. I will be more careful in the future. Thank you Eddie On Tue, 2006-03-28 at 11:45 +0530, Anant Narayanan wrote: > Eddie, > > > Can someone provide a good working example of GtkProgressBar in GTK2. > > The examples in the documentation don't seem to work properly and uses > > deprecated code. > > What?! Where?! It would be extremely helpful if you could let us know > which examples don't work and use deprecated code. Are you sure you are > viewing the latest PHP-Gtk2 docs? (http://www.php-gtk2.de/) > > > Examples are hard to find for us newbies. Are there any suggestions > > for finding good coding examples. > > We are constantly working towards adding examples to the documentation. > Meanwhile, looking at some of Christian's various PHP-Gtk2 apps, or the > Gtk2_Components PEAR packages could be of some help. > > As for the progress bar, one is implemented in the PEAR Package: > Gtk2_PHPConfig. Have a look at the showProgress() and updateProgress() > functions. > > Basically this is what you have to do: > > $x = new GtkWindow(); > $y = new GtkProgressBar(); > $y->set_orientation(Gtk::PROGRESS_LEFT_TO_RIGHT); > $x->add($y); > > for(i=0;i<100;i++) { > $y->set_fraction((float)($i/100.0)); > } > > $x->show_all(); > > Gtk::main(); > > This is a progress bar that will run very fast (because of the for > loop), but this is the basic idea. You must use the set_fraction() > whenever you want to update the progress. As I said, see the code for > Gtk2_PHPConfig for a proper realtime example. > > > I anxiously await the new (Pro PHP GTK book by Scott Mattocks) > > We all are! Release date is April 24th. Amazon is accepting pre-orders I > think. > > Regards,

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