A reduced version of my script that instantiates just one widget:
My PerlTK script has several Notebook tabs. Each tab has around 50 native_optionmenu button and each button has greater than 40 widgets.use Tk 800.000; use strict; my $width=45; # just right for 4 capital letters my $height=30; my @key_array = (); @key_array = split (//, "abcdefghijklmnopqrstuvwxyz"); @key_array = (@key_array, split (//, "0123456789" ) ); @key_array = (@key_array, qw(F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12) ) +; @key_array = (@key_array, qw(F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F +23 F24) ); @key_array = (@key_array, qw(Esc Bksp Del Ins Home End PgUp PgDn CapLk + Enter) ); @key_array = (@key_array, qw(Shift Ctrl Alt UpArr DnArr LtArr RtArr Pa +use) ); my $vvalue=""; my $mw = MainWindow->new; my $code_font = $mw->fontCreate('code', -family => 'ariel', -size => 1 +0); native_optionmenu( $mw, \$vvalue)->place( -width => $width, -height = +> $height); MainLoop; sub native_optionmenu { my($parent, $varref, ) = @_; my @optionvals = @key_array; my $mb = $parent->Menubutton( -textvariable => $varref, -indicatoron => 0, -relief => 'raised', -borderwidth => 2, -highlightthickness => 2, -anchor => 'c', -direction => 'flush', -font => $code_font, ); my $menu = $mb->Menu(-tearoff => 0); $mb->configure(-menu => $menu); my $ii =0; foreach (@optionvals) { $menu->radiobutton( -label => $_, -variable => $varref, ); $menu->entryconfigure($ii, -columnbreak => 1) unless $ii++ % 2 +6; } $mb; } # end native_optionmenu
My issue is when I get up to around 170 instances of native_optionmenu (across multiple tabs), then active perl on windows XP goes crazy. My widgets disappear. Clicking on the notebook tabs causes widgets to appear OUTSIDE the TK GUI window.
I am looking for suggestions on how to improve the performance. I think the issue is just too many widgets. I think if the native_optionmenu sub called another sub that poped up the window, then the performance would be better. I am not good enough yet with PerlTK to make the tweak. I am looking for tips.
In my perl script where I call the native_optionmenu, If replaces the call to 'Button' and the problem goes away.
Works: $$win->Button( -textvariable => \$vvalue$layout$layer$finger$direction)->place(-x => $colpos, -y => $rowpos, -width => $width, -height => $height);
Buggy behavior: native_optionmenu( $$win, \$vvalue$layout$layer$finger$direction)->place(-x => $colpos, -y => $rowpos, -width => $width, -height => $height);
Suggestions?
In reply to Multi column option menu by gator456
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |