WaitBox 
Author Message
 WaitBox

I'm trying to make a status bar while reading a rather large file.
One way to do this is, as far as I understand, to us the WaitBox
package.

In the documentation there is an example which use the following
construction:
my($u) = $wd->{SubWidget}(uframe);

In the description, however, there is a slightly different construction:

$w->subwidget{'uframe'}

But, I can't make any of them work.
Any hints?

Thanks in advance,

Knut Arne Borresen



Fri, 27 Jun 2003 19:15:40 GMT  
 WaitBox


Quote:
> I'm trying to make a status bar while reading a rather large file.
> One way to do this is, as far as I understand, to us the WaitBox
> package.

> In the documentation there is an example which use the following
> construction:
> my($u) = $wd->{SubWidget}(uframe);

> In the description, however, there is a slightly different
construction:

> $w->subwidget{'uframe'}

> But, I can't make any of them work.
> Any hints?

I would suggest using ProgressBar instead. I have used both and prefer
the latter. Just pack a ProgressBar and a Label (with the -textvariable
option) into a Toplevel.

Within your loop, or loading or whatever...update the values of the
ProgressBar variable and the Label textvariable as you see fit. You may
also have to do a:

$main->update;

as well.

Jack

Quote:

> Thanks in advance,

> Knut Arne Borresen


Sent via Deja.com
http://www.deja.com/


Sun, 29 Jun 2003 12:59:53 GMT  
 WaitBox
I'll bet that the original poster is trying to do something similar to what
I'm doing.  I'm also having problems but then again I didn't try becoming a
GUI or Tk programmer until last Thursday evening. ;-)  The code being
referenced is in the widget demo.

In my situation, I'm checking for the existence of some hardware and based
on the existence, I either display an error message or create a ProgressBar
in a subframe of a WaitBox.  When the error message is closed, I go back to
my main window.  My problem is with either the waitbox or the progress
bar.  The waitbox has a button labeled Abort which closes the window but
does not stop processing.  I adapted the following from the progressbar
demo in widget.

#create waitbox

$root->Busy;
$cfgResult = &checkForHardware($DEBUG,$pw,$address);
$root->withdraw;

if($cfgResult == 0){
    my $result = &displayErrorMsg($DEBUG,$u);
    if($result){
        $root->deiconify;
        $root->raise;
        $root->unBusy;
    }

Quote:
}else{

    &displayProgressBar($DEBUG,$root,$wd,$u,$pw);
    $root->destroy;
    exit 0;

Quote:
}

#....much code omitted....
sub displayProgressBar{
    #create progress bar....

    my($diff) = 33;

    for (1..$diff) {
        $percent = int($_/$diff*100);
        $utxt = sprintf("%5.0f%% Complete",$percent);
        $bar->update;
        last if !defined($utxt);
        sleep 1; #change to affect update speed of progress bar
        if ($percent==51) {
            #$root->configure(-txt2=>"Configuring stuff.  This will take a
few seconds.");
            $cfgResult = &do_something($DEBUG,$pw,$address);
        }
    }

Quote:
}

When the cancel button (Abort) for the waitbox is pressed, the entire
window is closed (as it should) but the processing of this loop continues
even though it is embedded in the same function that creates and displays
the progress bar.  It didn't go away even after explicitly destroying my
toplevel object.  What gives?  I have the Learning Perl/Tk book but it
doesn't explain enough about Tk event processing.  Do I have access to the
event caused by the button being pressed?

Is there any other reference material on Perl/Tk that I can read?

Thanks in advance!

John

Quote:



> > I'm trying to make a status bar while reading a rather large file.
> > One way to do this is, as far as I understand, to us the WaitBox
> > package.

> > In the documentation there is an example which use the following
> > construction:
> > my($u) = $wd->{SubWidget}(uframe);

> > In the description, however, there is a slightly different
> construction:

> > $w->subwidget{'uframe'}

> > But, I can't make any of them work.
> > Any hints?

> I would suggest using ProgressBar instead. I have used both and prefer
> the latter. Just pack a ProgressBar and a Label (with the -textvariable
> option) into a Toplevel.

> Within your loop, or loading or whatever...update the values of the
> ProgressBar variable and the Label textvariable as you see fit. You may
> also have to do a:

> $main->update;

> as well.

> Jack

> > Thanks in advance,

> > Knut Arne Borresen

> Sent via Deja.com
> http://www.deja.com/



Sat, 09 Aug 2003 05:24:38 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. where is Tk::WaitBox

2. WaitBox problem on Win95

3. Perl/Tk docs, Tk::WaitBox?

4. Tk::WaitBox

5. Problems compiling WaitBox example code

6. Waitbox Problems

7. a WaitBox problem

8. Waitbox and ProgressBar

9. Problems with Tk::WaitBox with Perl v5.004_02 under Windows 95

10. Tk::WaitBox - can't click "Cancel" button

 

 
Powered by phpBB® Forum Software