controlwidget(n)

πŸ“¦ version 0.7, in alpine 3.24

bestie, welcome to controlwidget(n) β€” part 1, and it’s giving β€œTk widgets but make it lab-core.” πŸ’…βœ¨

✨ NAME ✨

controlwidget β€” a whole collection of widgets for displaying and controlling numerical values.

πŸŽ€ SYNOPSIS πŸŽ€

These are the package requirements and command shapes, literally exactly like this:

package require Tcl ?8.5?

package require Tk ?8.5?

package require snit ?2.0?

package require controlwidget ?0.1?

::controlwidget::meter w args

::controlwidget::slider w args

::controlwidget::equalizerBar w args

::controlwidget::thermometer w args

::controlwidget::voltmeter w args

::controlwidget::tachometer w args

::controlwidget::rdial w args

$widget get

$widget set value

::controlwidget::led w args

::controlwidget::radioMatrix w args

$led on

$led off

$led setstate state

$matrix get

$matrix set index

πŸ’– DESCRIPTION πŸ’–

The controlwidget package is obsessed with displaying and interactively controlling numerical values. It mimics a bunch of meters and controls you’d find in lab settings, but also in daily life: volt meters, equalizers, and tachometers, to name a few. Think of them as alternatives for the scale widget. πŸ”₯

⚠️ Note: this package has not been extensively tested so far, and that may result in an unexpected appearance if you use sizes that are different than the defaults. Also, not all options for the coloring of the various parts and fonts and so on have been tested, so that may be another source of bugs. A last note: some parts have not been included in any option, most notably the colors of parts that require lighter and darker shades to cooperate.

πŸ¦‹ TYPES OF WIDGETS πŸ¦‹

The package distinguishes several types of widgets:

  • Vertical meters: the value of the variable is translated into a vertical position, like with the coloured bars you find on your stereo installation.
  • Angle displays: the value of the variable is related to the angle of a needle, like with tachometers.
  • Interactive widgets: most widgets allow you to change the value of the variable by pressing the mouse button on the needle and shifting it up and down or left and right.
  • Non-interactive widgets: some widgets, like the thermometer widget, do not allow such interaction.
  • Logical or choice widgets: some widgets display the values as either on/off (or true/false) or as one of a set of discrete choices.

All widgets have in common, however, that you can connect them to a variable and that changing the variable changes the display. Furthermore, all widgets have the set and get methods to interact with the value that the widget displays (whether that is stored in a global variable or not). 🫢

They also have in common that their appearance and behaviour is determined by one or more options that you can set at creation time and often later on as well. The widgets are all based on the snit package, so the methods configure and cget are available to set and get these options. πŸ’…

πŸ’… COMMANDS πŸ’…

Currently the package contains these widgets of the vertical meter type:

πŸŽ›οΈ ::controlwidget::meter w args

Create a vertical meter consisting of an axis and a moveable arrow.

  • widget w (in) β€” Name of the widget to be created.
  • arguments args (in) β€” List of key-value pairs, controlling the appearance and behaviour of the widget:
    • variable name β€” Name of the variable to be associated with the meter
    • background color β€” Background color for the widget
    • height pixels β€” Height of the widget
    • width pixels β€” Width of the widget
    • arrowthickness pixels β€” Thickness of the displayed arrow in pixels
    • arrowcolor color β€” Color of the displayed arrow
    • readonly boolean β€” Whether the arrow can be moved interactively or not

🎚️ ::controlwidget::slider w args

Create a widget containing one or more vertical sliders and an axis. You can shift the slider handles interactively via the mouse.

  • widget w (in) β€” Name of the widget to be created.
  • arguments args (in) β€” List of key-value pairs, controlling the appearance and behaviour of the widget:
    • variable name β€” Name of the (list) variable to be associated with the widget
    • number integer β€” Number of sliders in the widget
    • background color β€” Background color for the widget
    • height pixels β€” Height of the widget
    • width pixels β€” Width of the widget
    • sliderthickness pixels β€” Thickness of the slider handles
    • sliderwidth color β€” Width of the slider handles
    • troughwidth color β€” Width of the troughs holding the sliders

🌈 ::controlwidget::equalizerBar w args

Create a widget containing one or more vertical bars resembling those found on hifi graphical equalizers. Note that it is a read-only widget. πŸ‘‘

  • widget w (in) β€” Name of the widget to be created.
  • arguments args (in) β€” List of key-value pairs, controlling the appearance and behaviour of the widget:
    • variable name β€” Name of the (list) variable to be associated with the widget
    • number integer β€” Number of bars in the widget
    • background color β€” Background color for the widget
    • height pixels β€” Height of the widget
    • width pixels β€” Width of the widget
    • barwidth pixels β€” Width of the bars
    • segments integer β€” Number of segments the bars are divided in
    • safecolor color β€” Color for values lower than the warning level
    • warningcolor color β€” Color for values greater than the warning level
    • warninglevel double β€” Threshold value, determines at what level the color changes

🌑️ ::controlwidget::thermometer w args

Create a thermometer widget (read-only).

  • widget w (in) β€” Name of the widget to be created.
  • arguments args (in) β€” List of key-value pairs, controlling the appearance and behaviour of the widget:
    • variable name β€” Name of the (list) variable to be associated with the widget
    • background color β€” Background color for the widget
    • height pixels β€” Height of the widget
    • width pixels β€” Width of the widget
    • linethickness pixels β€” Thickness of the line representing the β€œtemperature”
    • linecolor color β€” Color of the line

These widgets all use a vertical axis and have the following options in common for configuring the axis:

  • axisformat string β€” Format string for formatting the numbers along the axis
  • axisfont string β€” Name of the font to be used for the numbers
  • axiscolor color β€” Color of the axis (including the numbers)
  • from color β€” Lower value for the axis
  • to color β€” Upper value for the axis
  • majorticks integer β€” Number of major tickmarks to draw (each is labelled)
  • minorticks integer β€” Number of minor tickmarks to draw between two major tickmarks
  • log boolean β€” Use a logarithmic axis (true) or a linear axis (false)

The package contains the following widget based on angle displays:

🧭 ::controlwidget::voltmeter w args

Create a voltmeter-like widget.

  • widget w (in) β€” Name of the widget to be created.
  • arguments args (in) β€” List of key-value pairs, controlling the appearance and behaviour of the widget:
    • variable name β€” Name of the variable to be associated with the meter
    • value value β€” Value for the meter (if not associated with a variable)
    • min value β€” The minimum value for data in the display
    • max value β€” The maximum value for data in the display
    • labels list β€” The labels to be shown along the scale. (These are simply considered texts, so no relation with the minimum and maximum perse)
    • title string β€” String to be shown below the dial
    • width pixels β€” The width of the widget
    • height pixels β€” The height of the widget
    • borderwidth pixels β€” The width of the border surrounding the entire widget
    • relief string β€” The relief of the border surrounding the entire widget
    • highlightthickness pixels β€” The width of the border to indicate the widget has keyboard focus
    • labelfont fontname β€” Font of the labels to the scale
    • titlefont fontname β€” Font of the title below the dial
    • dialcolor color β€” Color of the dial holding the needle
    • needlecolor color β€” Color of the needle
    • scalecolor color β€” Color of the scale (arc and tickmarks)
    • labelcolor color β€” Color of the labels to the scale
    • titlecolor color β€” Color of the title below the dial

🌈 ::controlwidget::tachometer w args 🌈

Bestie, it's a tachometer. Like a speedometer but for your revs. Iconic little dial, very dashboard-chic. πŸ’…

  • w (in) β€” Name of the widget to be created. Your baby needs a name, obviously.
  • args (in) β€” List of key-value pairs that control the appearance and behaviour of the widget. It's everything the voltmeter widget takes plus these extra deluxe keys:
    • variable name β€” Name of the variable to be associated with the meter.
    • value value β€” Value for the meter (use this if you're not associating it with a variable, iykyk).
    • dangerlevel value β€” Level above which values get indicated with a different color. Drama mode: activated. 🚨
    • dangercolor color β€” The color used for values above the "danger level".
    • dangerwidth pixels β€” Width of the colored band that shows off the "danger level".
    • pincolor color β€” Color for the needle and the pin. Both of them. Coordinated. πŸ‘‘

🎑 ::controlwidget::rdial w args 🎑

A rotating dial, and yes you can literally drag it to change the value β€” main character interaction fr. Hold Shift and the value changes slowly; hold Ctrl and it changes fast. Same deal with the mouse wheel: the shift and control buttons do exactly the same thing there too. Obsessed with the consistency.

⚠️ Heads up bestie: the shift and control buttons currently have no effect on Windows. Not a vibe, but it's the truth.
  • w (in) β€” Name of the widget to be created.
  • args (in) β€” List of key-value pairs controlling the appearance and behaviour of the widget:
    • variable name β€” Name of the variable to be associated with the dial.
    • value value β€” Value for the dial (for when there's no variable attached).
    • orient string β€” Whether you want a horizontal disk/dial ("horizontal") or a vertical one ("vertical"). Pick your aesthetic. πŸ¦‹
    • step value β€” Initial step for incrementing or decrementing the value.
    • bindwheel value β€” Step size for controlling the dial's value via the mouse wheel.
    • slow value β€” Factor applied to the step size for incrementing or decrementing the value slowly.
    • fast value β€” Factor applied to the step size for incrementing or decrementing the value fast.
    • scale value β€” Scale value that gets applied to the actual value.
    • callback command β€” Command that gets called when the value changes. Gossip channel πŸ’¬.
    • width pixels β€” The width of the widget.
    • height pixels β€” The height of the widget.
    • background color β€” Background color of the widget (that's the coloring of the disk/dial itself).
    • foreground color β€” Foreground color of the widget (the marker lines).

🫢 The methods literally all of these widgets share 🫢

$widget get

Returns the current value (or values) shown in the widget. Simple. Slay.

$widget set value

Resets the value or values shown in the widget. Oh and β€” if the widget is associated with a variable, that variable gets set too. Two birds. ✨

  • value double/list β€” New value or values for the widget.

πŸ’‘ Two more widgets, these ones are all about the logical values πŸ’‘

πŸ“ ::controlwidget::led w args πŸ“

Creates a LED-like widget. Tiny light. Massive energy. ⭐

  • w (in) β€” Name of the widget to be created.
  • args (in) β€” List of key-value pairs controlling the appearance and behaviour of the widget. Again, everything the voltmeter widget takes, plus:
    • variable name β€” Name of the variable to be associated with the LED.
    • size pixels β€” Diameter of the LED widget. Lil baby light or full-on beacon, your call.
    • on color β€” Color to use for the "on" state.
    • off color β€” Color to use for the "off" state.

πŸ”˜ ::controlwidget::radioMatrix w args πŸ”˜

Creates a whole matrix of radio buttons that behaves as a single widget. Group project but make it functional. πŸ‘‘

  • w (in) β€” Name of the widget to be created.
  • args (in) β€” List of key-value pairs controlling the appearance and behaviour of the widget. Yep, you guessed it β€” everything from the voltmeter widget, plus:
    • variable name β€” Name of the variable to be associated with the matrix.
    • orient string β€” The way the radio buttons are arranged (horizontal or vertical first).
    • rows integer β€” Number of rows in the matrix.
    • columns integer β€” Number of columns in the matrix.
    • command list β€” Command associated with the radio buttons. Gets invoked when the active radio button changes. πŸ””

πŸ’œ The LED widget's public methods πŸ’œ

$led on

Sets the state to "on". LET THERE BE LIGHT. πŸ”₯

$led off

Sets the state to "off". Nap time. 😴

$led setstate state

Sets the state according to the value of "state".

  • state boolean (in) β€” New state for the LED widget.

🧚 The radioMatrix widget's two public methods 🧚

$matrix get

Returns the index of the currently selected radio button.

$matrix set index

Selects the radio button with index "index".

  • index integer β€” Index of the radio button to be set.

🌸 ACKNOWLEDGMENTS 🌸

Real ones only. The code for most of these widgets first appeared on the Wiki, and in many cases Arjen Markus merely refactored the code a bit and "snitified" some of them (his words, not mine, and honestly iconic behaviour). The original code was developed by these legends:

  • Vertical meter, LED display, radio matrix: Ron Fox
  • Rotating dials: Gerhard Reithofer
  • Voltmeter and tachometer: Marco Maggi
  • Code for moving the needle: ?

(The mystery dev. The main character we never met. πŸ™ˆ)


πŸ’€ BUGS, IDEAS, FEEDBACK πŸ’€

Not gonna lie to you bestie, this document β€” and the package it describes β€” will undoubtedly contain bugs and other problems. Like, guaranteed. Please report them in the category controlwidget of the Tklib Trackers [http://core.tcl.tk/tklib/reportlist]. And please also report any ideas you may have for enhancements to either the package and/or the documentation. We want the glow-up. 🫢


⭐ KEYWORDS ⭐

controlling, displaying, numerical values, scale widget


Copyright (c) 2010 Ron Fox <rfox@...>
Copyright (c) 2010 Gerhard Reithofer <...@...>
Copyright (c) 2010 Marco Maggi <...@...>
Copyright (c) 2010 Arjen Markus <arjenmarkus@users.sourceforge.net>

Okay that's the whole page, bestie β€” you made it to the end! πŸŽ‰ This was controlwidget(n) from tklib, version 0.1, dated right there in the footer of the original. Go forth and build the prettiest little meters and dials and LED matrices anyone's ever seen. No cap. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from
  • alpine 3.24: tk-lib-doc 0.7-r0 Β· TCL
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms