Tsw

Tsw , by Csaba Nemethi, is a toggle switch widget package for Tcl/Tk 8.6 or higher, written in pure Tcl code.

Attributes

name
Tsw
location
https://www.nemethi.de
latest release
1.0
release time
2025-03
contact
Csaba Nemethi

Description

The Tsw package contains:

  • the implementation of the toggleswitch mega-widget, including a general utility module for mega-widgets;
  • two richly commented demo scripts containing the typical steps needed to create and handle toggleswitch widgets;
  • a tutorial in HTML format;
  • a reference page in HTML format.

A toggleswitch is a mega-widget consisting of a horizontal trough (a fully rounded filled rectangle) and a slider (a filled circle contained in the trunk). It can have one of two possible switch states: on or off. In the on state the slider is placed at the end of the trough, and in the off state at its beginning. The user can toggle between these two states with the mouse or the space key.

You can use the switchstate subcommand of the Tcl command associated with a toggleswitch to change or query the widget's switch state. By using the -command configuration option, you can specify a script to execute whenever the switch state of the widget gets toggled. For compatibility with the (ttk::)checkbutton, toggleswitch widgets also support the -offvalue, -onvalue, and -variable options.

Screenshots


Jeff Smith 2025-03-28 : Below is an online demo using CloudTk. This demo runs "Tsw" in an Alpine Linux Docker Container. It is a 46.6MB image which is made up of Alpine Linux + tclkit + Tsw1.0.kit + libx11 + libxft + fontconfig + ttf-linux-libertine +i3wm. It is run under a user account in the Container. The Container is restrictive with permissions for "Other" removed for "execute" and "read" for certain directories.

Jeff Smith 2025-03-28 : This demo now runs with Tcl9.