Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2024-04-24 16:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found