Tsw , by Csaba Nemethi, is a toggle switch widget package for Tcl/Tk 8.6 or higher, written in pure Tcl code.
The Tsw package contains:
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.
![]() | ![]() | ![]() |
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.