Home > Archive > PerlTk > November 2004 > Bug in Tk::Scrolled ?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Bug in Tk::Scrolled ?
|
|
|
| (I posted this in perl modules, also - probably should have been here
instead)
I think there is a bug in Tk::Scrolled when trying to use a balloon.
The tag doesn't seem to get dereferenced properly. If I do the
same thing with the Tk::Scrollbar, it works ok. Here is a sample script
that illustrates both methods, and shows the problem when you let the
mouse hover over the lines. I upgraded to the
latest Perl/Tk(804.027), and it still showed the "bug".
Any ideas?
Boyd
---------------------the script----------
#!/usr/bin/perl -w
use strict;
use Tk;
use Tk::Balloon;
my $mw = MainWindow->new;
my $tw = $mw->Toplevel;
my $sc = $mw->Scrolled('Canvas')->pack;
$sc->createLine(10,10,100,100,-tags=>'line1',-width=>5);
my $bal = $mw->Balloon;
$bal->attach($sc,-msg=>{line1=>'this is line1'});
my $sbx = $tw->Scrollbar(-orient=>'horizontal');
my $sby = $tw->Scrollbar(-orient=>'vertical');
my $cv = $tw->Canvas(
-xscrollcommand=>['set'=>$sbx],
-yscrollcommand=>['set'=>$sby],
);
$sbx->configure(-command=>[xview=>$cv]);
$sby->configure(-command=>[yview=>$cv]);
$sbx->pack(-side=>'bottom',-fill=>'x');
$sby->pack(-side=>'right',-fill=>'y');
$cv->pack(-side=>'left',-fill=>'both');
$cv->createLine(10,10,100,100,-tags=>'line2',-width=>5);
my $bal2 = $tw->Balloon;
$bal2->attach($cv,-msg=>{line2=>'this is line1'});
MainLoop;
| |
| Jack D 2004-11-16, 8:56 pm |
|
"boyd" <HeWillRejoice@yahoo.com> wrote in message
news:LUrmd.129$Zq3.125@fe61.usenetserver.com...
> (I posted this in perl modules, also - probably should have been here
> instead)
>
> I think there is a bug in Tk::Scrolled when trying to use a balloon.
> The tag doesn't seem to get dereferenced properly. If I do the
> same thing with the Tk::Scrollbar, it works ok. Here is a sample script
> that illustrates both methods, and shows the problem when you let the
> mouse hover over the lines. I upgraded to the
> latest Perl/Tk(804.027), and it still showed the "bug".
>
> Any ideas?
This is a common error. You must ensure you use the "real" canvas widget as
opposed to the frame container.
See changes embedded below.
>
> Boyd
> ---------------------the script----------
> #!/usr/bin/perl -w
>
> use strict;
> use Tk;
> use Tk::Balloon;
>
> my $mw = MainWindow->new;
> my $tw = $mw->Toplevel;
>
> my $sc = $mw->Scrolled('Canvas')->pack;
> $sc->createLine(10,10,100,100,-tags=>'line1',-width=>5);
> my $bal = $mw->Balloon;
my $realcanvas = $sc->Subwidget('scrolled');
$bal->attach($realcanvas,-msg=>{line1=>'this is line1'});
#######> $bal->attach($sc,-msg=>{line1=>'this is line1'});
>
> my $sbx = $tw->Scrollbar(-orient=>'horizontal');
> my $sby = $tw->Scrollbar(-orient=>'vertical');
>
> my $cv = $tw->Canvas(
> -xscrollcommand=>['set'=>$sbx],
> -yscrollcommand=>['set'=>$sby],
> );
> $sbx->configure(-command=>[xview=>$cv]);
> $sby->configure(-command=>[yview=>$cv]);
>
> $sbx->pack(-side=>'bottom',-fill=>'x');
> $sby->pack(-side=>'right',-fill=>'y');
> $cv->pack(-side=>'left',-fill=>'both');
>
> $cv->createLine(10,10,100,100,-tags=>'line2',-width=>5);
> my $bal2 = $tw->Balloon;
> $bal2->attach($cv,-msg=>{line2=>'this is line1'});
>
> MainLoop;
>
>
| |
|
| Thanks, Jack. Yes, I ran across the Subwidget method later and wondered
it that would fix it.
Boyd
Jack D wrote:
> "boyd" <HeWillRejoice@yahoo.com> wrote in message
> news:LUrmd.129$Zq3.125@fe61.usenetserver.com...
>
>
>
> This is a common error. You must ensure you use the "real" canvas widget as
> opposed to the frame container.
> See changes embedded below.
>
>
>
>
> my $realcanvas = $sc->Subwidget('scrolled');
> $bal->attach($realcanvas,-msg=>{line1=>'this is line1'});
>
>
> #######> $bal->attach($sc,-msg=>{line1=>'this is line1'});
>
>
>
>
|
|
|
|
|