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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |