How do trap and respond to a resize event for a widget in pTk?

For example, I'd like to be able to adjust the wraplength for a label as the size of the window changes. Is there an event I can bind to that will let me configure my Label as needed?

The code below demonstrates a Label widget that does not 'reflow' when the window is resized.

use strict; use warnings; use Tk; my $mw = MainWindow->new(); my $long_text = <<EOT; Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque + dictum tempor augue. Sed id pede. Suspendisse a erat a risus tincidu +nt rhoncus. Integer eget risus. Nulla nunc odio, viverra eget, consec +tetuer non, mollis at, felis. In hac habitasse platea dictumst. Nulla + accumsan volutpat eros. Vivamus convallis, eros ut convallis facilis +is, justo ipsum convallis orci, vehicula laoreet purus eros eget ante +. In tempor. Proin varius placerat nisl. Class aptent taciti sociosqu ad litora torquent per conubia nostra, pe +r inceptos hymenaeos. Aenean pretium augue ac nulla. Praesent ante ri +sus, iaculis et, malesuada a, luctus in, orci. Sed erat odio, auctor +sed, molestie vel, volutpat at, elit. Phasellus fermentum ultricies e +st. Aenean interdum elit sit amet est. Donec luctus lacus a turpis. S +ed et risus. Fusce metus. Pellentesque lorem dolor, volutpat in, cong +ue id, luctus et, magna. Nullam congue sagittis orci. Pellentesque ne +c metus. Nulla nulla. EOT # how can I force wraplegth to adjust as the main window (or container + frame) is resized? $mw->Label( -text => $long_text, -wraplength => 250, )->pack( -fill => 'both', -expand => 1, ); MainLoop;


TGI says moo


In reply to Handling resizing in pTk by TGI

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.