Last Review: Nov-26-2010


Problem: Perl/Tk 804.028 with Perl 5.10 disfunctional

Update: The problem, described below does not affect the combination of Perl 5.10.1 and Perl/Tk 804.029.

When running Perl > 5.8x (i.e. Perl 5.10) on Linux Boxes you can meet a problem running programs which use the Perl/Tk 804.028 toolkit: While everything seems to be properly installed, Perl/Tk based programs will only briefly flash a GUI window before crashing down.

Although on several net places it is claimed, that CPAN's Perl/Tk 804.028 module download has been already patched, I could'nt realise any change until now (January 2010). Thanks the OSS nature of this great piece of software we have chances to help ourselves! Just a few minutes work and you can take off again...



Solution

What we have to do is a short edit in the 'Widget.pm' file. Usually it resides in the '/usr' directory, so first we'll open a console and load that file to our favorite editor (the given example has been tested with Ubuntu 9.10 'Karmic Koala'):

# Make the target directory to our working directory, so we can
# see, if it exits, without doing anything else:
#
cd /usr/local/lib/perl/5.10.0/Tk/
#
# Now we open the target file as root:
#
sudo YourFavoriteEdior Widget.pm



My workaround shown here is a Quick And Dirty solution, not more (If you want to play with your mouses scroll wheel, may be you'll not be satisfied. Unfortunately the code's corresponding link to http://www.inria.fr/koala/colas/mouse-wheel-scroll/ seems to be broken).

First we search for the string 'sub MouseWheelBind', then the unconditioned binding (which may work fine under Windows) at the sub's beginning (file's line 1104) has to be commented out (as marked red below) before saving the file. Done.

sub MouseWheelBind
{
 my($mw,$class) = @_;

 # The MouseWheel will typically only fire on Windows. However, one
 # could use the "event generate" command to produce MouseWheel
 # events on other platforms.

 # $mw->Tk::bind($class, '<MouseWheel>',
 #             [ sub { $_[0]->yview('scroll',-($_[1]/120)*3,'units') }, Tk::Ev("D")]);

 if ($Tk::platform eq 'unix')
  {
   # Support for mousewheels on Linux/Unix commonly comes through mapping
   # the wheel to the extended buttons. If you have a mousewheel, find
   # Linux configuration info at:
   # http://www.inria.fr/koala/colas/mouse-wheel-scroll/
   $mw->Tk::bind($class, '<4>',
                 sub { $_[0]->yview('scroll', -3, 'units')
                           unless $Tk::strictMotif;
                   });
   $mw->Tk::bind($class, '<5>',
                 sub { $_[0]->yview('scroll', 3, 'units')
                           unless $Tk::strictMotif;
                   })
  }
}

Copyright © by Andreas-Josef v. Gencsy 2010

«« Home

AJvG is programmer of
vGShop - Copyright (c) 1999-2010 by A.-J. v. Gencsy
vGShop the managed Online Shop System