TIP 553: Ellipses: the Alternative to Scrolling and Wrapping

Login
    Author:         Donal K. Fellows <[email protected]>
    State:          Draft
    Type:           Project
    Vote:           Pending
    Created:        07-Nov-2019
    Post-History:
    Tcl-Version:    9.1
    Keywords:       Tk, label, listbox, entry

Abstract

This TIP proposes a mechanism for getting Tk widgets to insert an ellipsis instead of wrapping or scrolling (in widgets where this makes sense) a line of text.

Rationale

Adding an ellipsis when a piece of text is too wide to be shown in its entirety is a common modern GUI idiom, and one that is relatively easily implemented in Tcl/Tk as is. However, we do this in general by measuring the text (with font measure) by hand and determining where the ellipsis should be inserted, and then modifying the text itself to insert the ellipsis. This makes it difficult to make the position of the ellipsis change as the width of the widget changes, as we have to add code that observes the change to the View (via a <Configure> event on the widget) and update the Model in response, despite the true underlying Model not changing at all.

Instead, we should have the widgets do the work for us, so that we can just indicate what the true text is and tell Tk that it should insert ellipses as and where required without further user intervention.

Specification

When a widget supports applying an ellipsis, it will take a new option, -ellipsis, that will allow the specification of an ellipsis (as a string; there are multiple ways of expressing an ellipsis, and the right choice depends on other features of the interface) that gives a symbol to use after trimming off the text at a character boundary in order for the text including the ellipsis to fit inside the widget's width.

For label-based widgets (i.e., labels, buttons, checkbuttons, radiobuttons) the existing -wraplength will be used as the limit width for ellipsis insertion, where defined. Otherwise the width of the text part of the widget (based on the widget width and the impact of any compound images) will be used.

For the entry-based and listbox-based widgets (including spinboxes and comboboxes) the widget width will be used.

Note that the ellipsis insertion code will always use the font set in the widget, and widgets that are so narrow that they cannot display the ellipsis itself may look strange.

Implementation

To be done.

Copyright

This document is placed in public domain.