| Tk-Sugar documentation | view source | Contained in the Tk-Sugar distribution. |
( -fill => 'x' )( -fill => 'y' )( -fill => 'both' )fillx with ( -expand => 1 )fillyfill2( -expand => 1 ) if you don't like
the xfill* notation
( -padx => 1, -pady => 1 )( -ipadx => 1, -ipady => 1 )Tk::Sugar - Sugar syntax for Tk
version 1.093190
use Tk::Sugar qw{ :pack :state };
$widget->pack( top, xfill2, pad10 );
# equivalent to those pack options:
# -side => 'top'
# -expand => 1
# -fill => 'both'
# -padx => 10
# -pady => 10
$widget->configure( enabled );
# equivalent to: -state => 'enabled'
Tk is a great graphical toolkit to write desktop applications. However, one can get bothered with the constant typing of quotes and options. Tk::Sugar provides handy subs for common options used when programming Tk.
Benefits are obvious:
The constant need to type => and '' is fine for one-off cases,
but the instant you start using Tk it starts to get annoying.
Reduces much of the redundant typing in most cases, which makes your life easier, and makes it take up less visual space, which makes it faster to read.
Strings are often problematic, since they aren't checked at compile- time. Sometimes it makes spotting an error a difficult task. Using this alleviates that worry.
This module is using Sub::Exporter underneath, so you can use all its shenanigans to change the export names.
Look below for the list of available subs.
Traditional packer sides (available as :side export group):
( -side => 'top' )bottomleftrightPacker expand and filling (available as :fill export group):
( -fill => 'x' )( -fill => 'y' )( -fill => 'both' )fillx with ( -expand => 1 )fillyfill2( -expand => 1 ) if you don't like
the xfill* notationPacker padding (available as :pad export group):
( -padx => 1, -pady => 1 )Packer padding (available as :ipad export group):
( -ipadx => 1, -ipady => 1 )Widget state (available as :state export group):
( -state => 'normal' )disabledWidget anchor (available as :anchor export group). Note that those
subs are upper case, otherwise the sub s would clash with the regex
substitution:
( -anchor => 'n' )sewcenternenwseswWidget orientation (available as :orient export group).:
( -orient => 'horizontal' )verticalBeside the individual groups outlined above, the following export groups exist for your convenience:
This exports all existing subs.
This exports subs related to Tk::pack options. Same as :side,
:fill, :pad and :ipad.
This exports subs related to widget configure options. Same as
:state, :anchor and :orient.
You can look for information on this module at:
Jerome Quelin
This software is copyright (c) 2009 by Jerome Quelin.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
| Tk-Sugar documentation | view source | Contained in the Tk-Sugar distribution. |