Cross-platform Tcl/Tk Widgets

In addition to Mac-specific Tk widgets, Code by Kevin has also implemented some Tk widgets that add broad functionality to a Tk application, and which should run on any platform supported by Tcl/Tk. These packages are available on an open-source basis, below. See the packages for licensing terms.

TkWebView

TkWebView is a Tk widget based on the htmllib package and browser client developed by Stephen Uhler and maintained by Clif Flynt. It is intended to provide a lightweight HTML viewer for applications, either as a standalone window or as an embedded widget.

The source code for the original htmllib package is included in the htmllib-rel_0_3_4.zip file.

The same BSD-style license that applies to the older version of the package applies to the current modifications; see license.terms. The modifications are summarized in the documentation and are annotated in the source code with comments.

How to Use TkWebView

Under the hood, TkWebView is very complex, but it can be implemented very simply in an application. There are three main processes one can use:

See the demo source code in webview.tcl for more detailed examples on how to implement this widget in your application.

Download TkWebView

SimpleDND

The simpleDND package implements a lightweight mechanism for drag-and-drop operations within a single Tcl/Tk application. When used, it provides a visual icon and cursor change to indicate a dragged object, and can execute any Tcl command upon a successful drop operation. The package is designed to be easy-to-use, with just a few commands required to add drag-and-drop. Any widget can be registered as a drag source or drop target.

simpleDND is called via package require simpleDND. It is implemented with the following command:

simplednd::dragRegister must be called for each widget that is set up as a drag source. For instance, if you have a listbox .l and a listbox .b that are both drag sources, the command must be called for each widget. Also, if listbox .l and listbox .b have multiple drop targets, then the command must be called for each drop target.

The dragcmd should be used to configure the drag icon. The variables ::simplednd::dragtext and ::simplednd::dragimg are used for this purpose. At a minimum, you must define a single command setting default values for the dragtext and dragimg variables, or you can provide a different command for each drag operation. simpleDND does not provide default values for the text or image in the drag icon; without at least one dragcmd, you will be dragging around an empty label as the drag icon.

The dropcmd is called on a successful drop, i.e. when the button is released over the drop target registered with the drag source. If the button is released over a widget that is not registered as the drop target, the cursor changes to a standard arrow and the drag icon disappears.

Download SimpleDND


Text ©2012 WordTech Communications, LLC. See Credits for other acknowledgments.

 

Code by Kevin

Home/Products
Blog
Open Source
Contact
Newsletter
Sales Policies
Credits
About


Latest News


Twitter Updates