in reply to Perl/Tk exit trouble?

The book of which you complain was getting old, 10 years ago. It was the first Perl/Tk book written back in the heady days of the first Perl5's.... in other word it is obsolete and nobody cares. The book that is normally recommended by those who actually read the books, is Mastering Perl/Tk by the late Nick Ing Simmons.

Mr. Simmon's passing brings up another point about Perl/Tk, no one is actively pursuing improving the Perl/Tk port of the TCL/Tk..... Slaven Reszic is maintaining the latest Tk version, but it is starting to split off.... i think the Window's ActiveState ( which came with Tk built-in ) is now shipping their own spinoff called Tkx.

But it really dosn't matter.... if you want the latest, best, and most actively developed.... use Gtk2 or Wx ..... Tk still works, but it is falling behind Gtk2 fast like an old man chasing an 18 year old. :-) See Gtk2 free tutorial

If you can post a small code example, of code that has this exit problem, and state your Tk version, someone may know an answer..... install the latest version of Tk from cpan too.... it always pays to have the latest libs


I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku

Replies are listed 'Best First'.
Re^2: Perl/Tk exit trouble?
by Hengist (Pilgrim) on Jan 09, 2010 at 20:17 UTC

    Thank you,

    The Perl-Tk version is 804.027 and here is one of the scripts which misbehaves; as you can see, it's an exercise answer from one of the earlier chapters -

    #!/usr/bin/perl -w # 123ex1 - Combination of Entry and Label widgets. # Another segmentation fault; that's interesting. # # Setting the Label width forces the widget to scroll, # otherwise it will expand the window x-wise to # accomodate the extra text. Try -wraplength also. use Tk; use strict; my $message; my $mw = MainWindow->new; $mw->title("Label following Entry"); $mw->Label(-textvariable => \$message, -width => 40) ->pack(-side => 'bottom', -fill => 'x',); my $e = $mw->Entry(-textvariable => \$message) ->pack(-expand => 1, -fill => 'x'); MainLoop;

    I agree, the book is well out of date, but it was a cheap 'pre-loved' deal on Amazon. I've already give up on the book as a tutorial. Thanks for the advice about GTk2 - I may just follow that up.

      The Perl-Tk version is 804.027

      ... no that is an old version, now it it 804.028

      Many bug fixes have been incorporated in the move from .027 to .028

      See Cpan's Tk.... it's easy to install


      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku

        Thanks, zentara,

        I'll do that. Another monk (Thanks, stefbv) suggested I tried Gtk2 as it has greater current support, but in the brief look I took this afternoon, it's bigger, noisier and less intuitive than Perl/Tk. One of the things I love about Perl is the simplicity, and lack of unnecessary typing.

        I'm hoping that 804.028 may also help with the other bug I've uncovered; the mess made if I try to bind a key sequence involving the Ctrl key. For whatever reason, it transposes the last two characters in a Text widget; and I'm having to use the Alt key until I find a fix. Ho-hum.

        Thanks once again; I'm off to CPAN!

      No segmentation fault on my system (Slackware with Perl 5.10.0).

      the trouble may be with Tk, Perl or even the OS.

        I'm guessing it's Tk that's doing the wrong thing. I've used Perl in command-line for some weeks on this machine, and it's behaved superbly; it's only since I've started to learn Tk that the seg faults have manifested. They are probably harmless; they don't even get reported if the script is launched by a doubleclick.