PerlTk bug with ActivePerl on Windows XP

Posted by texan4ever on 2013-11-22 20:52
Forums: PPM | OS: Windows XP Pro

I have run into a bug with ActivePerl on WindowsXP. (I know its a bug because when I run the exact same perl script on Unix it works just fine.)

Perl.exe -v says v5.16.3 Binary build 1603

I am using PerlTK to build a GUI for a programmable keyboard. The script has a TK has a widget for each key on the keyboard. Each key has over 100 legal values. I have found this list to be too long for optionmenu type widget. So I borrowed the 'native_optionmenu' widget from the mastering Perl/TK book Chapter 12. The widget is similiar to optionmenu but allows for multiple columns.

A reduced version of my script that instantiates just one widget:

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, split (//, " \`\-\=\[\]\;\'\,\.\/\\\~\!\@\#\$") );
@key_array = (@key_array, split (//, " \%\^\&\*\(\)\_\+\{\}\:\"\<\>\?\|") );
@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 F23 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 Pause) );

my $vvalue="";

my $mw = MainWindow->new;
my $code_font = $mw->fontCreate('code', -family => 'ariel', -size => 10);
native_optionmenu( $mw, \$vvalue)->place( -width =>  $width, -height => $height);

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) {
            -label     => $_,
            -variable  => $varref,
        $menu->entryconfigure($ii, -columnbreak => 1) unless $ii++ % 26;

} # end native_optionmenu

My PerlTK script has several Notebook tabs. Each tab has around 50 native_optionmenu widget.

My issue is when I get up to around 170 instances of native_optionmenu (across multiple tabs), then active perl goes crazy. My widgets disappear. Clicking on the notebook tabs causes widgets to appear OUTSIDE the TK GUI window.

When I run the exact same perl script on UNIX it works fine.

In my perl script where I call the native_optionmenu, I replaces the call to 'Button' and the problem goes away.

$$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);