Tcl/Tk 8.3 enhanced the capabilities of the canvas widget through the incorporation of the popular “dash” patch, as well as providing incremental improvements to other Tcl/Tk features.
Tcl 8.3 incorporated several key contributed patches, particularly for Tk. Jan Nijtmans's dash and image patches provided many handy features such as dashed lines on the canvas, improved image support, and more. Bringing these patches into the Tcl core not only provided new features usable in general Tcl scripts, but it allowed people to use several popular extensions and tools without the need for manually applying these patches and recompiling Tcl.
The new file channels
command returns a list of open I/O channels, which can be sockets, regular files, or channels created by extensions. It accepts an optional glob pattern argument (e.g., sock*
) to constrain the list.
The file atime
and file mtime
commands now accept an optional argument to set the access time or modification time of the specified file. This gives you the ability to perform the equivalent of the Unix touch
command in pure Tcl code.
In addition to the previous ability to set file permissions using the same octal code format as the Unix chmod
command, the -permissions
option of the file attributes
command now allows you to set file permissions symbolically. You can use the same symbolic attributes as the Unix chmod
command (for example, u+s,go-rw
to add sticky bit for user and remove read and write permissions for group and other). A simplified ls
-style string, of the form rwxrwxrwx
(the string must be 9 characters) is also supported (for example, rwxr-xr-t
is equivalent to 01755).
New -directory
, -join
, -path
, and -types
options for glob
command make it easier to manipulate directories in a platform-independent manner. “Matching File Names with glob” on page 122 describes these new options.
Both regexp
and regsub
gained a -start
option, which indicates a starting offset into the string being matched. The new regexp
-inline
option can return the matching characters, rather than storing them in a variable. The regexp
-all
option finds all occurrences of the match pattern; in conjunction with the -inline
option it returns all the matches as a list, whereas without the -inline
option it returns the number of matches.
If you don't provide any variables to store the results of a scan
command, it now returns its matches directly as a list.
The new lsort
-unique
option removes duplicate elements from a list as it is sorted.
The new array unset
command deletes all elements from an array whose key matches be given glob-style pattern. If no pattern is provided, the command deletes the array variable and all of its elements.
The clock scan
command was extended to support common ISO 8601 date and time formats. An “easter egg” was included in both clock scan
and clock format
so that they understand the Stardate format (try %Q
with clock format
).
The clock clicks
-milliseconds
option was added to guarantee a millisecond granularity to the returned values.
The new pkg_mkIndex
-lazy
option generates a package index file that delays actual loading of a package until an application attempts to use one of the commands provided by the package. Without this option, the generate package immediately loads its command when an application executes it package require
command.
The Img
patch adds an alpha channel, better transparency support, and improved GIF support, including the ability to save GIF images. See the “Bitmaps and Images” section starting on page 625 for more information about these features. This patch also supports other image types (e.g., JPEG) that can be loaded as extensions; script-level support for other image types is typically provided through the Img extension, which can be used now without patching the Tcl core.
The “dash patch” added a variety of new Tk features — primarily to the canvas widget, but in other areas as well.
The dash patch provided several significant improvements to the canvas widget:
Canvas coordinates may be specified as a single list argument instead of individual arguments, which makes it easier to construct commands.
Many items now support the notion of a dash pattern for outlines, implemented through a variety of new item options containing the word dash
. Windows 95 supports only single-pixel wide dashed lines, whereas other platforms support thick dashed lines.
The canvas now includes a state
attribute, which modifies the default state of the canvas. Individual canvas objects all have their own -state
attributes, which may override the default canvas state. Items also have new attributes to control their appearance based upon their state. The attributes that start with -active
control the appearance when the mouse pointer is over the item, while the attributes starting with -disabled
control the appearance when the state is disabled. Additionally, disabled canvas items don't react to canvas bindings.
Advanced tag searching is available for all canvas operations that accept a tag or item ID as an argument. This adds the ability to search for canvas items based on boolean expressions of tag values.
The canvas can generate Postscript for embedded images on all platforms. Additionally, on Unix platforms, it can generate Postscript for embedded widgets currently displayed on the screen (that is, displayed within the canvas's viewport and not obscured by other windows).
The internal implementation of the canvas now uses Tcl_Obj
values, which improved its performance.
Tags in text widgets now include an -elide
attribute, to hide text with that tag. This feature is used by the popular TkMan manual page browser, which can be used now without patching the Tcl core.
Tk applications now have the ability to move the mouse under program control. Use the event generate
-warp
option when generating KeyPress, KeyRelease, ButtonPress, ButtonRelease, or Motion events. For example:
event generate .c <Motion> -warp 1 -x 10 -y 20
New options were added to the entry widget for input validation. The options specify command callbacks that are made at various times, such as when the entry widget takes input focus, loses input focus, or has its value change. The commands are subject to %
keyword substitution similar to the substitutions in event bindings. The keywords are used to get the name of the entry widget (e.g., %W
), the character that is being added, and so forth. (See “Entry Widget Validation” on page 822.)
Listboxes have a new listVariable
attribute to link the contents of the listbox to a variable that contains a list value (in much the same way that the textVariable
option is used in several other widgets). Listboxes also have new itemconfigure
and itemcget
operations to set and query the color of individual items.
A new tk_chooseDirectory
command allows users to browse a directory hierarchy and select a directory, in much the same way as the tk_getOpenFile
command works for regular files.
The wm state
command now accepts an optional argument allowing you to set the state of a toplevel. On Windows systems, wm state
also supports a new zoomed
state for maximized windows.
On Windows systems, you can now use Windows system cursors in .ani
and .cur
files by using the format -cursor @
filename
when setting a widget's cursor.
Default binding were added to listbox and text widgets so that on Unix system that report mousewheel events as <ButtonPress-4>
and <ButtonPress-5>
events, the listbox and text widgets respond to the mousewheel.
A new tk useinputmethods
command changes the behavior of Tk on X where X Input Methods (XIM) were recognized and used without question. With 8.3, they are recognized and initialized, but not used unless XIM is turned on (tk useinputmethods 1
). This should only affect users with special input methods, and the new default behavior should be more beneficial to the average user.
A series of 8.3 patch releases mainly provided incremental improvements and bug fixes, but did add a few new features. The 8.3.5 patch release was a final stabilization release for the 8.3 series, and was released concurrently with version 8.4.1. The only significant new feature of 8.3.5 versus the previous patch release was the ability of the canvas to generate Postscript for embedded widgets on Windows platforms, which was concurrently added with the 8.4.1 patch release.
The %V
substitution for entry widget validation reports the type of validation that triggered the callback (key
, focusin
, focusout
, forced
). (8.3.1)
On the Macintosh — when Navigation Services are installed — the tk_getOpenFile
and tk_getSaveFile
commands accept a -message
option to specify a message to include in the client area of the dialog. (8.3.1)
The label widget now supports a state
attribute, with normal
, active
, and disabled
states. (8.3.1) Additionally, it has new activeBackground
and activeForeground
attributes to control its appearance in the active
state (8.3.2), and a disabledForeground
attribute to control its appearance in the disabled
state (8.3.1).
On Windows systems, you can provide the path of a valid Windows icon file (usually .ico
or .icr
files) when setting the window's icon with the wm iconbitmap
command. (8.3.3)
18.219.36.249