problems with progress bars and functions
| From: | Rob Cornelius | Date: | Mon, 03 Nov 2003 16:21:35 +0000 |
| Subject: | problems with progress bars and functions | ||
| Groups: | php.gtk.general | ||
| Request: | Send a blank email to php-gtk-general+get-4048@lists.php.net to get a copy of this message | ||
Hi there,
I am a bit of a newbie when it comes to php-gtk I admit. I am trying to write a very simple app for parsing csv files and using the data to update a DB.
At the moment I can get a file select dialog to appear when i click on the screen and the code get the path from this and pass it through to my code to work on the file is fine. To be honest if it was for me that is all I need. I would just leave it running until it finished and then call a destroy function to close the window.
But... as always this has to be idiot proof.
All I want is an activity progress bar to start when the processing takes place and stop when its done.
My function to open the FileSelector is as follows
function FileDialog($progressbar) {
$progressbarclass = get_class($progressbar);
print "progress in filedialog= $progressbarclass\n";
$fs = &new GtkFileSelection('File Selection Example');
$ok_button = $fs->ok_button;
$ok_button->connect('clicked', 'engine', $fs, $progressbar);
$ok_button->connect('clicked', 'enddialog', $fs);
$ok_button->connect_object('clicked', array($fs, 'destroy'));
$cancel_button = $fs->cancel_button;
$cancel_button->connect('clicked', 'canceldialog');
$cancel_button->connect_object('clicked', array($fs, 'destroy'));
$fs->show();
}
Lots of it copied and pasted from the php-gtk example ;)
I cant find anywhere how to link this to the progress bar. How do I pass the progress bar into this function? When i try
$button->connect('clicked', 'FileDialog', $progressbar);
Fatal error: Call to an undefined function: get_filename() C:\Documents and Settings\rob\Desktop\updater2.php on line 100
which referrs to
function engine ($fs) {
$path = $fs->get_filename();
$handle = fopen($path, 'r');
$progressbar->start_update(); <--- THIS ONE
while (!feof($handle)) {
$buffer = fgets($handle, 4);
print "$buffer\n";
}
fclose ($handle);
$progressbar->stop_update;
return true;
}
When I examine the class the progress bar is a member of inside the FileDialog function it tell me it has transformed from a GtkProgressBar to a GtkButton!
any help would be really appreciated
Rob