TkLua_01 - Display of "Windows System Colors"
"TkLua_01" displays a "list" of system colors as defined by Microsoft Windows
(and accessible from within Tk). As an additional feature, upon a click into
any of the square color display areas (see figure below) the status line
shows the RGB definition of the selected color. To achieve this behaviour
the program exploits the possibility to "bind" specific event handling routines
to every widget of a Tk user interface.
Despite the program's principal simplicity, it seems convenient to point
out the following details:
-
using TkLua, widgets whose content is arranged by means of the "geometry
manager" "grid" do not support all features offered by Tk. E.g., the attempt
to set the "sticky" attribute within the object list just yields an error
message;
-
the later configuration of certain widgets by means of explicitly issued
Tk commands (and the TkLua function "tkeval") will fail unless these
widgets have already been "mapped" onto the display - not before then the
required "tkname" has been assigned to the corresponding TkLua objects.
"TkLua_01" should be invoked without any command line arguments
lua TkLua_01.lua
and presents itself as follows:

Screenshot of the TkLua_01 Application Window
Source Code
The source code of this example is available for download:
References
| [1] |
Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar
Celes
Reference Manual of the Programming Language Lua 4.0
(see http://www.lua.org/manual)
the reference manual contains any relevant information about the language
itself, the set of standard libraries and its interface to the run-time
environment; |
| [2] |
Waldemar Celes
tklua - Binding Tk to Lua
(see
http://www.tecgraf.puc-rio.br/~celes/tklua/)
TkLua provides support for Tk widgets (allowing to construct graphical user
interfaces) from within Lua scripts. The given web page describes the "basic
concepts" behind TkLua and explains how to use it from within Lua scripts; |
| [3] |
Christian Vogler
TkLua (4.0a1)
(see
http://www.cis.upenn.edu/~cvogler/lua/tklua.html)
since the original distribution of TkLua [2] has been developed for Lua versions
prior to 4.0, Christian Vogler ported TkLua to the new Lua 4.0 API; |
| [4] |
Tcl/Tk 8.3.4 Manual
(see
http://www.scriptics.com/man/tcl8.3/)
if you plan to use TkLua for your Lua script, you will hardly survive without
the Tcl/Tk documentation - it can be viewed online at the given address (unless
you already downloaded the Tcl/Tk distribution onto your system and installed
it there); |
|