X Cramps > TkUtil-Configure > TkUtil::Configure

Download:
TkUtil-Configure-0.03.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.03   Source  

NAME ^

TkUtil::Configure - Trap and act on Tk <Configure> events

VERSION ^

Version 0.03

SYNOPSIS ^

Fairly intelligent trapping of <Configure> events within Perl/Tk.

    use TkUtil::Configure;

    my $conf = TkUtil::Configure->new(top => $mw, callback => ??);

All you currently have is the constructor, because that's all that is needed. See below for additional information.

DESCRIPTION ^

In Perl/Tk programming, you often want to bind to the <Configure> event so that you can elegantly resize your internal windows when the main window is resized.

The problem is that a simple resize can generate hundreds of resize events. And if the job you must do in a window is complex or time consuming, handling all of these events can be problematic.

That's what this class was written for... to bind the <Configure> event, and deal with all of the incoming events in a reasonable fashion, and only call your callback function(s) when we think the user is done.

The callback function(s) are where you do the necessary redrawing of the window(s), of course.

This was written (and made available) because too many people struggle with this issue (me included). Most people simply give up and don't allow (or deal with) resize at all, because the issue is such a problem. Enjoy.

AUTHOR ^

X Cramps, <cramps.the at gmail.com>

BUGS ^

Please report any bugs or feature requests to bug-tkutil-configure at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=TkUtil-Configure. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT ^

You can find documentation for this module with the perldoc command.

    perldoc TkUtil::Configure

You can also look for information at:

COPYRIGHT & LICENSE ^

Copyright 2009 X Cramps, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

new

  $conf = TkUtil::Configure->new(top => ??, callback => ??, %opts);

%opts can be:

  on      - provide a widget id to trigger the callback for [1]
  timeout - amount of time before a callback is generated (in msec) [2]

top is the toplevel widget upon which to bind the <Configure> event.

Note that both on and callback can be array references. You can have multiple widgets specified in on and only a single callback if you like (since the first argument to the callback is the widget, the callback can behave differently based upon it).

    [1] callback is called when the top widget is configured (resized). It
    is called with the widget id and the new width and height of the 
    widget under 
    consideration (I<on>). I<on> is the widget id to trigger this
    particular callback for.

    [2] when a widget is resized, we get LOTS of <Configure> events.
    Even with fast computers, you can overload with events if
    you need to do something complex when the user resizes. The
    timeout allows you to build up events until the last event
    was I<timeout> msec ago, and only then trigger a callback.
    The default is 500 msec (1/2 second). Your callback won't
    be called unless I<timeout> msec has elapsed from the last
    <Configure> event.

culled

  $conf->culled();

Find how many events were culled for you.

syntax highlighting: