displaying of Tk::Optionmenu
listmail <[email protected]> Wed, 22 Nov 2006 17:18:22 -0500
| Newsgroups | gmane.comp.lang.perl.tk |
|---|---|
| Message-ID | <[email protected]> |
A Tk::Optionmenu typically displays it’s drop down list for its options
just below the drop down selector. When the Tk::Optionmenu is located
close to the bottom of the screen (such as near the windows taskbar) and
the option list is too long to have room to display its list below the
drop down select, it will display the list upwards which ends up
overlapping the menu selector. I suppose the display portion could be
something that is handled by the window manger and not necessarily
Tk::Optionmen/Tk::Menubutton etc.
I would like to have it start displaying the contents from the top of
the drop down selector and move upward when the list is too long to
display downward. One of the main reasons for this is that is easy for
the end user to accidentaly select the wrong option when it overlaps and
draws itself under the current mouse position as well. Can anyone give
me a clue as to how I could get things work as I describe? Does this
problem exist in the more recent versions of Tk?
#1) To implement what I am describing first click the Option menu just
after running the script
#and notice that it draws the list of items below the menu button
without overlapping.
#
#2) Next ~maximize~ the Tk window which now places the Option menu down
near the windows
#taskbar. When clicking the Option menu this time it should start to
display the options from the
#bottom of the menu button, but move upward and overlap the menu button
itself.
#
#!/usr/bin/perl -w
use strict;
use warnings;
use Tk;
my $server;
my @serverlist;
for (my $x=0; $x < 10; $x++) {
push @serverlist, "BOX$x";
}
my $mw=MainWindow->new;
my $frame1 = $mw->Frame();
my $frame2 = $mw->Frame();
#text box added for cosmetics only
my $textbox=$frame1->Text(-height=> 20, -width=> 50)->pack(-fill=>
'both', -expand=> 1);
my $serverdropmenu=$frame2->Optionmenu(-variable=> \$server, -options=>
\@serverlist)->pack;#(-side=>'left', -padx=>2);
$frame1->pack(-fill=> 'both', -expand=> 1);
$frame2->pack;
MainLoop;
##
# Windows XP
# ActivePerl 5.8.7 Build 813
# I couldn’t find the packaged version of Tk that I’m using through ppm
--++**==--++**==--++**==--++**==--++**==--++**==--++**==
ptk mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/ptk