As AM points out above, in a very nice article I might add, you've linked to a tutorial whose Perl code is for Tkx. Here's a Tk version:

use Tk; use Scalar::Util qw{looks_like_number}; my ($feet, $metres) = (q{}, q{}); my $mw = MainWindow->new(-title => q{Feet to Metres}); my $f = $mw->Frame() ->grid(-padx => 12, -pady => 3, -sticky => q{nsew}); my %pad = (-padx => 5, -pady => 5); my $feet_E = $f->Entry(-textvariable => \$feet, -width => 7) ->grid(-row => 0, -column => 1, -sticky => q{we}, %pad); $f->Label(-text => q{feet}) ->grid(-row => 0, -column => 2, -sticky => q{w}, %pad); $f->Label(-text => q{is equivalent to}) ->grid(-row => 1, -column => 0, -sticky => q{e}, %pad); $f->Label(-textvariable => \$metres) ->grid(-row => 1, -column => 1, -sticky => q{we}, %pad); $f->Label(-text => q{metres}) ->grid(-row => 1, -column => 2, -sticky => q{w}, %pad); my $calc_B = $f->Button(-text => q{Calculate}, -command => sub { $metres = looks_like_number($feet) ? int(0.3048 * $feet * 10000.0 + 0.5) / 10000.0 : q{}; })->grid(-row => 2, -column => 2, -sticky => q{w}, %pad); $feet_E->focus(); $mw->bind(q{<Return>} => sub {$calc_B->invoke()}); MainLoop;

-- Ken


In reply to Re^2: GUI toolkit+designer for the perl newbie by kcott
in thread GUI toolkit+designer for the perl newbie by faibistes

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.