Tkx

Tkx is yet another Tk interface.
Download

Tkx Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Gisle Aas
  • Publisher web site:
  • http://search.cpan.org/~gaas/

Tkx Tags


Tkx Description

Tkx is yet another Tk interface. Tkx is yet another Tk interface.SYNOPSIS use Tkx; my $mw = Tkx::widget->new("."); $mw->new_button( -text => "Hello, world", -command => sub { $mw->g_destroy; }, )->g_pack; Tkx::MainLoop();The Tkx module provides yet another Tk interface for Perl. Tk is a GUI toolkit tied to the Tcl language, and Tkx provides a bridge to Tcl that allows Tk based applications to be written in Perl.The main idea behind Tkx is that it is a very thin wrapper on top of Tcl, i.e. that what you get is exactly the behaviour you read about in the Tcl/Tk documentation with no surprises added by the Perl layer.The following functions are provided:Tkx::MainLoop( ) This will enter the Tk mainloop and start processing events. The function returns when the main window has been destroyed. There is no return value.Tkx::Ev( $field, ... ) This creates an object that if passed as the first argument to a callback will expand the corresponding Tcl template substitutions in the context of that callback. The description of Tkx::foo below explain how callback arguments are provided. The $field should be a string like "%A" or "%x". The available substitutions are described in the Tcl documentation for the bind command.Tkx::SplitList( $list ) This will split up a Tcl list into Perl list. The individual elements of the list are returned as separate elements: @a = Tkx::SplitList(Tkx::set("a")); This function will croak if the argument is not a well formed list or if called in scalar context.Tkx::foo( @args ) Any other function will invoke the foo Tcl function with the given arguments. The name foo first undergo the following substitutions of embedded underlines: foo_bar --> "foo", "bar" # break into words foo__bar --> "foo::bar" # access namespaces foo___bar --> "foo_bar" # when you actually need a '_' This allow us conveniently to map most of the Tcl namespace to Perl. If this mapping does not suit you, use Tkx::i::call($func, @args). This will invoke the function named by $func with no name substitutions or magic. Examples: Tkx::expr("3 + 3"); Tkx::package_require("BWidget"); Tkx::DynamicHelp__add(".", -text => "Hi there"); if (Tkx::tk_windowingsystem() eq "x11") { ... } if (Tkx::tk___messageBox( ... ) eq "yes") { ... } The arguments passed can be plain scalars, array references, code references, or scalar references. Array references are converted to Tcl lists. The arrays can contain other plain scalars or array references to form nested lists. For Tcl APIs that require callbacks you can pass a reference to a Perl function. Alternatively an array reference with a code reference as the first element, will allow the callback to receive the rest of the elements as arguments when invoked. If the second element of the array is an Tkx::Ev() object, then the templates it contain will be expanded at the time of the calllback. Some callback examples: Tkx::after(3000, sub { print "Hi" }); Tkx::button(".b", -command ); Tkx::bind(".", "", n"; }, Tkx::Ev("%A")]); Tkx::bind(".", "", ); For Tcl APIs that require variables to be passed, you might pass a reference to a Perl scalar. The scalar will be watched and updated in the same way as the Tcl variable would. The Tcl string result is returned in both scalar and array context. Tcl errors are propagated as Perl exceptions. If the boolean variable $Tkx::TRACE is set to a true value, then a trace of all commands passed to Tcl will be printed on STDERR. This variable is initialized from the PERL_TKX_TRACE environment variable. The trace is useful for debugging and if you need to report errors to the Tcl maintainers in terms of Tcl statements. The trace lines are prefixed with: Tkx-$seq-$ts-$file-$line: where $seq is a sequence number, $ts is a timestamp in seconds since the first command was issued, and $file and $line indicate on which source line this call was triggered.All these functions can be exported by Tkx if you grow tired of typing the Tkx:: prefix. Example: use strict; use Tkx qw(MainLoop button pack destroy); pack(button(".b", -text => "Press me!", -command => )); MainLoop;No functions are exported by default.Requirements:· Perl Requirements: · Perl


Tkx Related Software