Hi Discipulus

thanks for the code links.

> if you have a case where repetition is needed providing some %default is better tan nothing and suffices.

The example in the OP had only one method, the point of with is to handle many different methods on the same object.

with is available in many languages, tho Tk might be the wrong field for applying it.

The other default options were optional, but it surprised me a lot that Tk needed it. Must be related to the TCL brige.

> Why? Because I generally cut and paste my own code.

Well, personally I prefer DRY over boilerplating, but YMMV.

I looked into your code, and I see plenty of possibilities to improve readability.

may I suggest:

{ my $Entry = sub { my ($self,$textvar) = @_; return $self ->Entry(-width => 3,-borderwidth => 4, -textvariable => $t +extvar) ->pack(-side => 'left', -expand => 1,-padx=>5); }; # ... $fr2a->$Entry(\$size_help); }

instead of many instances of

$fr2a->Entry(-width => 3,-borderwidth => 4, -textvariable => \$size_he +lp)->pack(-side => 'left', -expand => 1,-padx=>5);

same for other methods.

Please note that you can

> Corion is right:

TIMTOWTDI ... but YMMV :)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

update

improved code for method-wrapper.


In reply to Re^4: Verbose Tk Code by LanX
in thread Verbose Tk Code by LanX

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.