GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Tk::Sugar(3) User Contributed Perl Documentation Tk::Sugar(3)

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:

  • Reduced typing.

    The constant need to type "=>" and '' is fine for one-off cases, but the instant you start using Tk it starts to get annoying.

  • More compact statements.

    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.

  • No string worries.

    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.

Pack options

Traditional packer sides (available as ":side" export group):

  • top - equivalent to "( -side => 'top' )"
  • bottom - ditto for "bottom"
  • left - ditto for "left"
  • right - ditto for "right"

Packer expand and filling (available as ":fill" export group):

  • fillx - equivalent to "( -fill => 'x' )"
  • filly - equivalent to "( -fill => 'y' )"
  • fill2 - equivalent to "( -fill => 'both' )"
  • xfillx - same as "fillx" with "( -expand => 1 )"
  • xfilly - ditto for "filly"
  • xfill2 - ditto for "fill2"
  • expand - equivalent to "( -expand => 1 )" if you don't like the "xfill*" notation

Packer padding (available as ":pad" export group):

  • pad1 - equivalent to "( -padx => 1, -pady => 1 )"
  • pad2 - ditto with 2 pixels
  • pad5 - ditto with 5 pixels
  • pad10 - ditto with 10 pixels
  • pad20 - ditto with 20 pixels
  • pad($n) - ditto with $n pixels (function call with one argument)
  • padx($n) - x padding with $n pixels (function call with one argument)
  • pady($n) - y padding with $n pixels (function call with one argument)

Packer padding (available as ":ipad" export group):

  • ipad1 - equivalent to "( -ipadx => 1, -ipady => 1 )"
  • ipad2 - ditto with 2 pixels
  • ipad5 - ditto with 5 pixels
  • ipad10 - ditto with 10 pixels
  • ipad20 - ditto with 20 pixels
  • ipad($n) - ditto with $n pixels (function call with one argument)
  • ipadx($n) - internal x padding with $n pixels (function call with one argument)
  • ipady($n) - internal y padding with $n pixels (function call with one argument)

Common options

Widget state (available as ":state" export group):

  • enabled - equivalent to "( -state => 'normal' )"
  • disabled - ditto for "disabled"

Widget anchor (available as ":anchor" export group). Note that those subs are upper case, otherwise the sub "s" would clash with the regex substitution:

  • N - equivalent to "( -anchor => 'n' )"
  • S - ditto with "s"
  • E - ditto with "e"
  • W - ditto with "w"
  • C - ditto with "center"
  • NE - ditto with "ne"
  • NW - ditto with "nw"
  • SE - ditto with "se"
  • SW - ditto with "sw"

Widget orientation (available as ":orient" export group).:

  • horizontal - equivalent to "( -orient => 'horizontal' )"
  • vertical - ditto with "vertical"

Beside the individual groups outlined above, the following export groups exist for your convenience:
:default
This exports all existing subs.
:pack
This exports subs related to Tk::pack options. Same as ":side", ":fill", ":pad" and ":ipad".
:options
This exports subs related to widget configure options. Same as ":state", ":anchor" and ":orient".

You can look for information on this module at:
  • Search CPAN

    <http://search.cpan.org/dist/Tk-Sugar/>

  • Open / report bugs

    <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Tk-Sugar>

  • Git repository

    <http://github.com/jquelin/tk-sugar.git>

  • AnnoCPAN: Annotated CPAN documentation

    <http://annocpan.org/dist/Tk-Sugar>

  • CPAN Ratings

    <http://cpanratings.perl.org/d/Tk-Sugar>

  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.

2009-11-15 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.