WIDGETPLUS(3tk)
โจ widgetPlus โ NAME โจ
okay bestie, gather round ๐ this is the manual page for widgetPlus (section 3tk), and it is literally the glow-up your text-input widgets have been begging for.
widgetPlus โ Enhanced Entry, Spinbox, and Combobox Widgets with Undo/Redo and other useful features ๐ฆ
๐ธ SYNOPSIS ๐ธ
package require Tcl 8.5
package require Tk 8.5
package require snit
package require widgetPlus ?1.0?
widgetPlus::entryPlus ?create? pathName
widgetPlus::spinboxPlus ?create? pathName
widgetPlus::ttkEntryPlus ?create? pathName
widgetPlus::ttkSpinboxPlus ?create? pathName
widgetPlus::ttkComboboxPlus ?create? pathName
widgetPlus::EnableBWidget
pathName edit ?arg arg ...?
pathName edit canredo
pathName edit canundo
pathName edit modified ?boolean?
pathName edit redo
pathName edit reset
pathName edit separator
pathName edit undo
๐ DESCRIPTION ๐
So here's the tea, bestie ๐: the widgetPlus package takes the widgets entry, spinbox, ttk::entry, ttk::spinbox, and ttk::combobox, and gives them a whole new personality.
The new features are Undo and Redo operations, a <<Selection>> event, and โ for the Tk (unthemed) widgets โ an -inactiveselectbackground option, plus some minor fixes to bindings. The new facilities closely follow those of the text widget. no cap, it's giving text-widget energy โจ
The revised entry, spinbox, ttk::entry, ttk::spinbox, and ttk::combobox widgets are created by the commands widgetPlus::entryPlus, widgetPlus::spinboxPlus, widgetPlus::ttkEntryPlus, widgetPlus::ttkSpinboxPlus, and widgetPlus::ttkComboboxPlus respectively.
For example, the widgetPlus::entryPlus widget is implemented as a Snit snit::widgetadaptor that wraps a Tk entry widget. Its winfo class is Entry, and it uses a binding tag EntryPlus that replaces the Entry binding tag. The other widgets are implemented in a similar way. ๐ง
The package uses the namespace ::widgetPlus, which exports (only) the five commands defined below that begin with a lower-case letter (EnableBWidget is not exported). These commands can be imported into the global namespace, and for simplicity, descriptive text in this manual will henceforth omit the namespace qualifier.
namespace import ::widgetPlus::*
๐ WIDGET OPTIONS ๐
On top of the usual options of the entry, spinbox, ttk::entry, ttk::spinbox, and ttk::combobox widgets, the wrappers entryPlus, spinboxPlus, ttkEntryPlus, ttkSpinboxPlus, and ttkComboboxPlus provide the options below. ๐
-inactiveselectbackgroundโ Command-Line Switch:-inactiveselectbackground; Database Name:inactiveSelectBackground; Database Class:Foreground. Specifies the color to use for the selection when the window does not have the input focus. If empty,{}, then no selection is shown when the window does not have the focus. The-inactiveselectbackgroundoption has no effect on the Ttk (themed) widgetsttkEntryPlus,ttkSpinboxPlus, andttkComboboxPlus.-maxundoโ Command-Line Switch:-maxundo; Database Name:maxUndo; Database Class:MaxUndo. Specifies the maximum number of compound undo actions on the undo stack. A zero or a negative value imply an unlimited undo stack. ๐-undoโ Command-Line Switch:-undo; Database Name:undo; Database Class:Undo. Specifies a boolean that says whether the undo mechanism is active or not.
โญ COMMANDS โญ
widgetPlus::entryPlus ?create? pathNameโ Create anentryPluswidget; or convert an existingentrywidget into anentryPlus. ๐ซถwidgetPlus::spinboxPlus ?create? pathNameโ Create aspinboxPluswidget; or convert an existingspinboxwidget into aspinboxPlus.widgetPlus::ttkEntryPlus ?create? pathNameโ Create attkEntryPluswidget; or convert an existingttk::entrywidget into attkEntryPlus.widgetPlus::ttkSpinboxPlus ?create? pathNameโ Create attkSpinboxPluswidget; or convert an existingttk::spinboxwidget into attkSpinboxPlus.widgetPlus::ttkComboboxPlus ?create? pathNameโ Create attkComboboxPluswidget; or convert an existingttk::comboboxwidget into attkComboboxPlus.widgetPlus::EnableBWidgetโ Enable widgetPlus to modify BWidgetEntrywidgets and their compounds (such as the BWidgetComboBox). The command creates a bindtagBwEntryPlusto replace the default bindtagBwEntry. This operation is not performed when the package is loaded because it requires BWidget to be loaded first. This command is not exported from namespace::widgetPlus.
๐ WIDGET COMMANDS ๐
On top of the usual commands of the entry, spinbox, ttk::entry, ttk::spinbox, and ttk::combobox widgets, the wrappers entryPlus, ttkEntryPlus, spinboxPlus, ttkSpinboxPlus, and ttkComboboxPlus provide: ๐
pathName edit ?arg arg ...?โ This command controls the undo mechanism and the modified flag. The exact behavior of the command depends on the option argument that follows theeditargument. The following forms of the command are currently supported:pathName edit canredoโ Returns a boolean true if redo is possible, i.e. when the redo stack is not empty. Otherwise returns false.pathName edit canundoโ Returns a boolean true if undo is possible, i.e. when the undo stack is not empty. Otherwise returns false.pathName edit modified ?boolean?โ If boolean is not specified, returns the modified flag of the widget. Theinsert,delete,edit undoandedit redocommands, or (by using this command) the user, can set or clear the modified flag. If boolean is specified, sets the modified flag of the widget to boolean.pathName edit redoโ When the-undooption is true, reapplies the last undone edits provided no other edits were done since then. Generates an error when the redo stack is empty. Does nothing when the-undooption is false.pathName edit resetโ Clears the undo stack and redo stack. ๐งนpathName edit separatorโ Included for completeness, but has no effect.
(N.B. An implicit separator is added to the undo stack for each call to a widget command (e.g.insertordelete) that changes the widget contents. These therefore separate the addition or removal of individual characters by typing, except that cut or paste operations are discrete.)
pathName edit undoโ Undoes the last edit action when the-undooption is true. An edit action is defined as a singleinsertordeletecommand that is recorded on the undo stack. Generates an error when the undo stack is empty. Does nothing when the-undooption is false.
๐ฆ BINDINGS ๐ฆ
๐ CLASS BINDINGS ๐
The class binding tag for different widgets has these default values:
entryusesEntryspinboxusesSpinboxttk::entryusesTEntryttk::spinboxusesTSpinboxttk::comboboxusesTComboboxentryPlususesEntryPlusspinboxPlususesSpinboxPlusttkEntryPlususesTEntryPlusttkSpinboxPlususesTSpinboxPlusttkComboboxPlususesTComboboxPlus
๐ซ UNDO AND REDO ๐ซ
The <<Undo>> and <<Redo>> virtual events are mapped to these keyboard events:
- On X11 systems (Linuxยฎ, BSDยฎ, Solarisยฎ, etc):
<<Undo>>is mapped to<Control-z><<Redo>>is mapped to<Control-Shift-z>
- On Windowsยฎ systems:
<<Undo>>is mapped to<Control-z><<Redo>>is mapped to<Control-y>
- On Aquaยฎ systems (i.e. Appleยฎ macOSยฎ or OS Xยฎ):
<<Undo>>is mapped to<Command-z><<Redo>>is mapped to<Command-Shift-z>
๐ธ ENTRYPLUS ๐ธ
The EntryPlus bindings are based on those of the Entry bindtag, with these changes:
- New bindings to
<<Undo>>and<<Redo>>. - An adjustment to the
<<Paste>>binding, so that it behaves the same way on X11 as on other windowing systems (i.e. it deletes the existing selection, if any exists). - The removal of the antiquated
<Insert>binding. ๐ (gone, bestie, it's over) - New bindings to
<FocusIn>and<FocusOut>, to facilitate the implementation of the-inactiveselectbackgroundoption.
๐ SPINBOXPLUS ๐
The SpinboxPlus bindings are based on those of the Spinbox bindtag, with the same changes as are made when converting Entry to EntryPlus.
โจ TENTRYPLUS โจ
The TEntryPlus bindings are based on those of the TEntry bindtag, with these changes:
- New bindings to
<<Undo>>and<<Redo>>.
๐ฅ TSPINBOXPLUS ๐ฅ
The TSpinboxPlus bindings are based on those of the TSpinbox bindtag, with these changes:
- New bindings to
<<Undo>>and<<Redo>>.
๐ TCOMBOBOXPLUS ๐
The TComboboxPlus bindings are based on those of the TCombobox bindtag, with these changes:
- New bindings to
<<Undo>>and<<Redo>>.
๐ซถ VIRTUAL EVENT <<Selection>> ๐ซถ
Each widgetPlus widget generates a virtual event <<Selection>> whenever the value of its selection changes. This allows other Tcl code, for example the package persistentSelection, to monitor the selection in these widgets. ๐ main character surveillance energy, but make it wholesome.
๐ง USE WITH MEGAWIDGETS ๐ง
When an entry, spinbox, ttk::entry, ttk::spinbox, or ttk::combobox is a component of a megawidget, it is often possible to apply widgetPlus to that component without modifying the megawidget code. obsessed. โจ
๐ COMBOBOX (BY BRYAN OAKLEY) ๐
A combobox with path $w includes an entry widget $w.entry, which uses the Entry binding tag. Thus widgetPlus can be applied to the combobox after creation, using the command (see EXAMPLES)
entryPlus $w.entry -undo 1 -maxundo 0
๐ COMBOBOX (BWIDGET) ๐
A BWidget ComboBox with path $w includes an entry widget $w.e, which uses the BwEntry binding tag in place of the default tag Entry.
Package widgetPlus provides a replacement bindtag BwEntryPlus, but this is not computed when the package is loaded because it requires BWidget to be loaded first. The command ::widgetPlus::EnableBWidget must be called to provide BwEntryPlus, and then the BWidget ComboBox can be modified (see EXAMPLES)
::widgetPlus::EnableBWidget
entryPlus $w.e -undo 1 -maxundo 0
๐ TO DO ๐
Okay bestie, here's the tea on what is still not done โ the authors are literally telling us the homework isn't finished, and honestly? We respect the transparency. ๐ซถ
- Undo and Redo do not sync the value of the modified flag โ they always set the value to boolean
true. Like, always. No nuance, no cap. ๐ - Undo and Redo do not sync the position of the insertion cursor. The cursor stays where it stays. She has her own plans.
- The
<<Modified>>event is not generated. So don't sit there waiting for it, bestie, she's not coming. ๐ - Undo/Redo separators, and the
-autoseparatorsoption, as found in thetextwidget, are not implemented. What does happen instead: an implicit separator is added for each call to a widget command (e.g.insertordelete) that changes the widget contents. And theedit separatorcommand? Yeah โ it has no effect. The page notes that separator functionality would be less useful for widgets such asentryPlusthan it is for atextwidget. - Add an overwrite mode, toggled by
<Insert>on non-macOSยฎ systems. On the wishlist, not in the code yet. ๐ฆ
๐ BUGS ๐
This version of widgetPlus is intended to be compatible with all releases of Tk 8.5 and 8.6, and with the branches core-8-5-branch, core-8-6-branch, and trunk in the source code repository for Tk. So if you find any incompatibility with any of these versions, for any Tk windowing system โ that is a bug, and it should be reported as one. Please report such in the category widgetPlus of the Tklib Trackers [http://core.tcl.tk/tklib/reportlist]. ๐
โจ EXAMPLES โจ
๐ entryPlus from scratch, unlimited undo
To create and map an entryPlus widget .ep with an unlimited Undo/Redo stack:
package require widgetPlus
widgetPlus::entryPlus .ep -undo 1 -maxundo 0
pack .ep
๐ same thing, but with namespace import
The same but using namespace import:
package require widgetPlus
namespace import widgetPlus::*
entryPlus .ep -undo 1 -maxundo 0
pack .ep
๐ glow-up an existing entry into an entryPlus
To convert an existing entry widget .ee into an entryPlus with an unlimited Undo/Redo stack:
entry .ee
.
.
.
package require widgetPlus
widgetPlus::entryPlus .ee -undo 1 -maxundo 0
๐ธ ...and the namespace import version of that
The same but using namespace import:
entry .ee
.
.
.
package require widgetPlus
namespace import widgetPlus::*
entryPlus .ee -undo 1 -maxundo 0
๐ฆ Bryan Oakley combobox glow-up
Apply widgetPlus to a Bryan Oakley combobox:
package require combobox
combobox::combobox .cb
.
.
.
package require widgetPlus
namespace import widgetPlus::*
entryPlus .cb.entry -undo 1 -maxundo 0
๐ BWidget ComboBox glow-up
Apply widgetPlus to a BWidget ComboBox. The command ::widgetPlus::EnableBWidget must be called first โ do not skip this step, bestie, it is literally the whole vibe.
package require BWidget
ComboBox .cb
.
.
.
package require widgetPlus
::widgetPlus::EnableBWidget
namespace import widgetPlus::*
entryPlus .cb.e -undo 1 -maxundo 0
๐ซถ BUGS, IDEAS, FEEDBACK ๐ซถ
This document, and the package it describes, will undoubtedly contain bugs and other problems โ iconic behaviour, honestly. Please report such in the category widgetPlus of the Tklib Trackers [http://core.tcl.tk/tklib/reportlist]. And please also report any ideas for enhancements you may have for either the package and/or the documentation. We want your thoughts, fr fr. ๐
๐ SEE ALSO ๐
BWidgetComboBoxEntryentrypersistentSelectionspinboxtextttk::comboboxttk::entryttk::spinbox
and that's the whole page, bestie!! ๐โจ This one ships as part of tklib, version 1.0, and the manual page itself is widgetPlus(3tk) โ go forth, undo and redo your little heart out, and remember: every flag was listed, every example copied character-for-character, and nothing got summarised. periodt. ๐
๐
๐ฆ where this page comes from
- debian trixie: tklib 0.9-1
- ubuntu questing: tklib 0.9-1
- ubuntu resolute: tklib 0.9-1build1
- ubuntu stonking: tklib 0.9-1build1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms