Re: GtkProgressBar Example
| From: | Anant Narayanan | Date: | Tue, 28 Mar 2006 06:15:24 +0000 |
| Subject: | Re: GtkProgressBar Example | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-6823@lists.php.net to get a copy of this message | ||
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,
--
Anant
Find Freedom, Go Open Source!
http://www.kix.in/