For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > December 2005 > determine if optional scrollbar visible









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 determine if optional scrollbar visible
listmail

2005-12-04, 6:58 pm

Is there anyway I can determine if an optional scrollbar (defined as
part of a scrolled hlist widget) is currently visibile or not?

-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu

Ala Qumsieh

2005-12-05, 3:57 am

listmail wrote:
> Is there anyway I can determine if an optional scrollbar (defined as
> part of a scrolled hlist widget) is currently visibile or not?


By using the ismapped() method that is documented in Tk::Widget:

print 'Horizontal bar is ',
($hlist->Subwidget('xscrollbar')->ismapped ? '' : 'not ' ),
"visible\n";

But, personally, I'm against optional scrollbars. Either have visible
scrolllbars, or don't have scrollbars at all. Optional ones introduce an
element of surprise to end users, that might keep them thinking that
other surprises might be in store.

--Ala

Jack D.

2005-12-05, 7:01 pm


> -----Original Message-----
> From: owner-ptk@lists.Stanford.EDU
> [mailto:owner-ptk@lists.Stanford.EDU] On Behalf Of listmail
> Sent: December 4, 2005 3:38 PM
> To: ptk@lists.Stanford.EDU
> Subject: determine if optional scrollbar visible
>
> Is there anyway I can determine if an optional scrollbar
> (defined as part of a scrolled hlist widget) is currently
> visibile or not?


Use the "ismapped" method documented in Tk::Widget.

Here is an example using a Scrolled('Text') widget.

###############################
use Tk;
use strict;

my $check='';
my $mw=tkinit;
my $t=$mw->Scrolled('Text',
-wrap=>'none',
-scrollbars=>'osoe')->pack(-fill=>'both', -expand=>1);
$mw->Button(
-text=>'Check for scrollbar',
-command=>\&checkForScroll)->pack;
$mw->Label(-textvariable=>\$check)->pack(-fill=>'x');
MainLoop;


sub checkForScroll
{
my $yscroll = $t->Subwidget('yscrollbar');
my $xscroll = $t->Subwidget('xscrollbar');
if ($yscroll->ismapped and $xscroll->ismapped) {
$check="Both scrollbars are mapped";
}
elsif ($yscroll->ismapped) {
$check="Y Scrollbar is mapped";
}
elsif ($xscroll->ismapped) {
$check="X Scrollbar is mapped";
}
else {
$check="No Scrollbars are mapped";
}
$mw->after(1500,sub{$check=''});
}
__END__
###############################
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com