controlwidget(3tk)

πŸ“¦
version 0.9 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ NAME ✨

controlwidget β€” a whole lil family of widgets for displaying and controlling numerical values πŸ’…


🌈 SYNOPSIS 🌈

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 πŸ’–

okay so bestie, controlwidget is obsessed with one thing: showing numbers and letting you mess with them. It straight up copies the vibe of all the meters and controls you'd find in a lab πŸ”¬ β€” but also just, like, in your daily life? Volt meters, equalizers, tachometers, to name a few. Think of them as the cooler, glowed-up alternative to the plain scale widget. periodt.

⚠️ real talk though: this package has not been tested extensively so far. So if you use sizes that aren't the defaults, you might get a look that's... unexpected πŸ™ˆ. Also not every option for coloring the various parts, fonts, etc. has been tested, so that's another possible source of bugs. not me exposing my own package πŸ’€

and one last note before we dive in: some parts haven't been given an option at all β€” most notably the colors of parts that need lighter and darker shades to cooperate with each other. so yeah, those just do their thing on their own πŸŽ€


πŸ¦‹ TYPES OF WIDGETS πŸ¦‹

The package keeps several types of widgets, and honestly the range is iconic:

  • Vertical meters β€” your value gets translated into a vertical position, like those coloured bars on your stereo setup 🎚️
  • Angle displays β€” your value maps to the angle of a needle, tachometer style 🧭
  • Interactive widgets β€” most of them let you change the variable's value by pressing the mouse button on the needle and dragging it up/down or left/right πŸ–±οΈ
  • Non-interactive widgets β€” some of them, like the thermometer widget, are just gonna stand there and not let you do that. read-only energy 🧊
  • Logical or choice widgets β€” these show values either as on/off (or true/false), or as one of a discrete set of choices πŸ”˜

But here's what they all have in common, no cap:

  • you can connect them to a variable, and changing the variable changes the display
  • they all have the set and get methods to interact with the value the widget displays β€” whether that value is stored in a global variable or not
  • their appearance and behaviour is determined by one or more options you can set at creation time, and often later on too. They're all built on the snit package, so the methods configure and cget are available for setting and getting those options ✨

πŸ‘‘ COMMANDS πŸ‘‘

Right now the package ships with these widgets of the vertical meter type:


πŸŽ€ ::controlwidget::meter w args

Makes a vertical meter β€” an axis plus a moveable arrow. it's giving speedometer but upright πŸ’«

  • 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 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

Makes a widget with one or more vertical sliders plus an axis. You can shift the slider handles interactively with the mouse β€” main character energy, honestly 🫢

  • 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 (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

Makes a widget with one or more vertical bars, exactly like the ones on hifi graphical equalizers 🎡 Just know that it's a read-only widget, so no dragging bestie, only admiring.

  • 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 (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

Makes a thermometer widget. yes it's read-only. no you cannot poke the mercury 🌑️

  • 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 (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

🧚 the axis options they ALL share

Every one of those widgets above uses a vertical axis, and they all have these options in common for configuring that 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 one 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 also contains the following widget based on angle displays:


⭐ ::controlwidget::voltmeter w args

Makes a voltmeter-like widget. the needle really does the most πŸ”₯

  • 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 meter
    • value value β€” value for the meter (if it's 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

Create a tachometer-like widget. It’s giving dashboard, but make it Tcl. πŸŽοΈπŸ’¨

  • 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. In addition to the ones given for the voltmeter 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)
    • dangerlevel value β€” Level above which values are indicated with a different color
    • dangercolor color β€” Color for the values above the "danger level"
    • dangerwidth pixels β€” Width for the colored band indicating the "danger level"
    • pincolor color β€” Color for the needle and the pin

✨ ::controlwidget::rdial w args

Create a rotating dial. You can drag the dial to change the value. With the shift button depressed the value changes slowly, with the control button depressed it changes fast. Similarly, you can control the dial via the mouse wheel, with the shift and control button working in the same way as with the mouse pointer.

Note: The shift and control buttons currently have no effect on Windows.
  • 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 dial
    • value value β€” Value for the dial (if not associated with a variable)
    • orient string β€” Whether a horizontal disk/dial is required ("horizontal") or a vertical one ("vertical")
    • 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 on the step size for incrementing or decrementing the value slowly
    • fast value β€” Factor on the step size for incrementing or decrementing the value fast
    • scale value β€” Scale value to be applied to the actual value
    • callback command β€” Command to be called when the value changes
    • width pixels β€” The width of the widget
    • height pixels β€” The height of the widget
    • background color β€” The background color of the widget (coloring of the disk/dial)
    • foreground color β€” The foreground color of the widget (the marker lines)

All these widgets have the following methods:

  • $widget get β€” Return the current value or values shown in the widget
  • $widget set value β€” Reset the value or values shown in the widget. If the widget is associated with a variable, that variable is set as well.
    • value double/list β€” New value or values for the widget

Two further widgets are available, meant to display logical values:

πŸ’‘ ::controlwidget::led w args

Create a LED-like widget. tiny glow-up, literally. ✨

  • 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. In addition to the ones given for the voltmeter widget:
    • variable name β€” Name of the variable to be associated with the LED
    • size pixels β€” Diameter of the LED widget
    • on color β€” Color to use for the "on" state
    • off color β€” Color to use for the "off" state

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

Create a matrix of radio buttons that behaves as a single widget. bestie, it’s a whole grid of choices, no cap.

  • 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. In addition to the ones given for the voltmeter widget:
    • variable name β€” Name of the variable to be associated with the matrix
    • orient string β€” The way the radio buttons are to be 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. Invoked when the active radio button changes.

The LED widget has the following public methods:

  • $led on β€” Set the state to "on"
  • $led off β€” Set the state to "off"
  • $led setstate state β€” Set the state according to the value of "state"
    • state boolean (in) β€” New state for the LED widget

The radioMatrix widget has two public methods:

  • $matrix get β€” Return the index of the currently selected radio button
  • $matrix set index β€” Select the radio button with index "index"
    • index integer β€” Index of the radio button to be set

🌟 ACKNOWLEDGMENTS 🌟

The code for most of these widgets first appeared on the Wiki. In many cases, Arjen Markus merely refactored the code a bit and "snitified" some of them. The original code was developed by the following people:

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

πŸ› BUGS, IDEAS, FEEDBACK πŸ›

This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category controlwidget of the Tklib Trackers [http://core.tcl.tk/tklib/reportlist]. Please also report any ideas for enhancements you may have for either package and/or documentation.


πŸ”‘ 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 bestie, that’s the whole controlwidget(3tk) page from tklib 0.1 πŸ’– the footer didn’t give a date, but you know I’d timestamp it with sparkles if I could. stay iconic, keep those widgets slaying, and don’t forget to report bugs. periodt. πŸ’…πŸ¦‹

πŸ“¦ where this page comes from