[ET] 2023-12-27 cooltip 1.6 This is an upgrade to '''tooltip 1.6''' found in the '''Tklib'''. It supports tips with 7 configurable color text tags and 3 styles. Another 9 extra tags can be configured by program control for advanced use. A separate '''GUI''' editor is included to build cool tips with style. Unicode up to \uFFFF is supported. It is upwards compatible with existing tooltip code, as it uses the same namespace, tooltip:: and the same commands, including the configuration options from the latest tooltip version 1.6. The Tooltip 1.6 options for -index, -items, -tag, and -tab can be added as specified in the tooltip 1.6 manual. https://www.amazon.com/photos/shared/_sI94t9zRtGkEcmi-DMQqQ.OOsisst3y_EaLh8bkoiBFY%|%Screen Shot%|% ---- === Quick test drive: === 1. Expand the first discussion below, scroll to the code block and click the copy button in the upper right corner. 2. Create a file '''cooltip-1.6.tm''' and paste in the code and save the file in a new directory. 3. Repeat for the second discussion, name the file '''cool.tcl''' 4. '''cd''' to the directory containing the 2 files, and run: '''wish cool.tcl''' 5. You should see 2 windows, the cooltip GUI and a console. Hover the mouse over the various buttons in the cooltip GUI window. 6. Read ahead for more information or click exit in the console or close the GUI window. ---- === See here for the documentation on tooltip 1.6: https://core.tcl-lang.org/tklib/doc/trunk/embedded/md/tklib/files/modules/tooltip/tooltip.md === Cooltip is bundled with a GUI tip builder to build more stylish tips. The tip builder also demonstrates the kinds of tips that can be built using the tool. The cooltip 1.6 package is assumed to be a '''Tcl module''' and should therefore be placed in a file named: === cooltip-1.6.tm === The GUI builder assumes that it and the cooltip module are in the same directory and is run with a '''wish file.tcl''' command. It uses [[info script]] to know where it and the cooltip module reside. It can have any name, but must be able to find the cooltip module. Cooltip works with 2 types of tips, but uses the same command. The options are those from tooltip 1.6 used to designate such things as menu index, text widget tags, listbox items, and ttk::notebook tabs. === tooltip::tooltip ?options? === If is a regular text string, then it should work the same as with tooltip 1.6. One builds a styled tip using the GUI builder, and when ready for use clicks the copy button. This will create the tip text as a '''text widget dump''' assigned to a variable with a === '''set tooltipN {##}''' === statement and places it onto the clipboard. Then would be '''$tooltipN''' rather than a litteral text string. N can be any text. A styled tip text is prefixed with ## to differentiate it from a non-styled tip. This can then be pasted from the clipboard into the user program, possibly replacing an earlier version. To re-edit one copies this set statement and pastes it back into the GUI builder. This eliminates any need for intermediate files. However, the GUI is also able to save to and load from a pair of fixed filenames (in the [[pwd]] directory) for quick backups of text and configuration settings. If the user does any '''advanced configuration''' of the text tags, these are saved in the 2nd file of the pair as a single tcl source-able statement; this can be simply added to the user program if they were changed in the GUI console. The Config settings apply to all tips, so the config is not saved with each individual tip. All unicode chars inserted by the builder, are reverted back to their \uXXXX escapes before copied to the clipboard for pasting into the program. When pasted back into the GUI builder it will parse the set statement extracting the text dump re-creating the tip in its text window. The GUI builder uses the Tk text widget, and so supports all the standard shortcuts. It also handles undo (control-z) but only the text, not the attributes. On windows, redo is control-y and shift-control-z on linux. In addition, a control-wheel will increase or decrease the config value for the font. '''Note''': the GUI program's copy/paste buttons (on the menubar) are not raw copy/paste, but specialized to work only on the '''set''' statements exclusively. Regular copy/paste is supported by the text widget shortcuts (control-c/control-v). [ET] 1/13/2024 - recent changes - mirror changes in the tooltip widget config (when entering config changes via the console window) into the editor widget and added the control-mousewheel for font size zooming. Load and Save should also remember any config changes too. New is the configure option with a dialog to configure most attributes of each color 1/14/2024. Reworked the clear command, added awdark if available 1/15. And fixed console on linux code for 9.0. Font chooser in configure. Bug fix, performance fix. 1/18 ---- The '''user program''' would either find the cooltip module in a known module directory with a simple '''package require cooltip''', or similar to '''auto_path''', use the module command '''tcl::tm::path add ''' to let the package command find the module in the folder specified. A user program could also just '''source''' the module or even simply '''embed''' it into the program (it's relatively small at ~800 lines). The GUI builder is not needed at runtime in the target user program. ---- Below in the discussion is the cooltip module, which as mentioned, should be named cooltip-1.6.tm and placed in either a known module directory, or in the same directory with the GUI builder that follows. <> In most cases, the built in 7 colors and 3 styles with a single font should be sufficient for most tool tips. However, using the config option one can create very elaborate tips using multiple fonts, colors, and other attributes. For example, superscripts can be created using a smaller font with the -offset option. Cooltip also includes 2 config options, -extraw and -extrah to increase the width and height of all tooltips and defaults to 0. In addition to the 7 colors, which can be configured if desired (e.g. to change the actual color) there are 9 extra tags grey51..grey59 which are available for full configuration using any option for a text widget tag. These are not used by the GUI program so changing them won't interfere with its own tips. When text is changed to one of those colors, it will have a grey background and when hovering over with the mouse pointer, a tooltip will identify the color assigned. When using a '''tooltip::tooltip config''' with no options, it will output all the current values. The color options can also include other attributes, such as -font as well as modifications to the color itself (e.g. note how -grey is actually set to grey80). Each option value is a list of text widget tag options. To remove a tag option, set to {}. The GUI builder also includes an enhanced console for windows and linux. When it starts up, it pre-loads the history with a few sample configuration commands that can be retrieved and edited using the up arrow key. This provides a way to test config's of say the 9 grey5n tags with a quick feedback using the GUI's ->test widget. In the below sample commands entered into the GUI's console, one can see all the config settings and change of grey51's font and relief settings. One could then select text and assign it to color grey51 which would also modify the other attributes. === % tooltip::tooltip config -foreground black -background lightyellow -font {FixedSys 10} -red {-foreground red} -green {-foreground green} -blue {-foreground lightblue} -orange {-foreground orange} -violet {-foreground violet} -black {-foreground black} -grey {-foreground grey80} -grey51 {-background grey90 -foreground black -selectbackground lightblue} -grey52 {-background grey90 -foreground black -selectbackground lightblue} -grey53 {-background grey90 -foreground black -selectbackground lightblue} -grey54 {-background grey90 -foreground black -selectbackground lightblue} -grey55 {-background grey90 -foreground black -selectbackground lightblue} -grey56 {-background grey90 -foreground black -selectbackground lightblue} -grey57 {-background grey90 -foreground black -selectbackground lightblue} -grey58 {-background grey90 -foreground black -selectbackground lightblue} -grey59 {-background grey90 -foreground black -selectbackground lightblue} -extraw 0 -extrah 0 % tooltip::tooltip config -grey51 -background grey90 -foreground black -selectbackground lightblue % tooltip::tooltip config -grey51 {-font {courier 12} -relief ridge -borderwidth 4} % tooltip::tooltip config -grey51 -background grey90 -borderwidth 4 -font {courier 12} -foreground black -relief ridge -selectbackground lightblue === Note that with multiple fonts one will likely need to pad lines on the right with spaces so the geometry is accurate. Similarly, one may need extra blank lines at the bottom. The -extraw and -extrah are global options and effect all tips and could be used as well. ====== # # # cooltip-1.6.tm # # # tooltips with colors # # Copyright (c) 1996-2007 Jeffrey Hobbs # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # RCS: @(#) $Id: tooltip.tcl,v 1.16 2008/12/01 23:37:16 hobbs Exp $ # # Initiated: 28 October 1996 # As modified by ET 25 dec 2023 package require Tk 8.5- package require msgcat #------------------------------------------------------------------------ # PROCEDURE # tooltip::tooltip # # DESCRIPTION # Implements a tooltip (balloon help) system # # ARGUMENTS # tooltip