Author: Emiliano Gavilán <emil.gavilan@gmail.com>
State: Draft
Type: Project
Created: 16-Apr-2026
Tcl-Version: 9.1
Tk-Branch: tip-751-labels-rotated-text
Keywords: Tk, MS-Windows, label, ttk::label
Vote: In progress
Vote-Summary:
Votes-For:
Votes-Against:
Votes-Present:
Abstract
This TIP proposes adding a switch to change a toplevels decoration to dark mode on MS-Windows.
Rationale
When building GUIs, there are uses which would require the ability to display text rotated at right angles (90°, 270°) or more generally, at an arbitrary angle. Tk has had the ability to display such text in a canvas since the implementation of TIP 119, but this ability it is not used elsewhere. This TIP proposes the use of angled text in labels, both tk and ttk.
As a side effect of ttk design, this also enables other ttk widgets to benefit from the ttk::label implementation, since both text and label elements are used on other ttk widgets besides ttk::label. One of such widgets is ttk::notebook, which can use rotated labels on tabs when they are positioned on the sides.
This TIP does not expose the rotated text functionality at C level. This can be done on a follow-up TIP.
Specification
label and ttk::label widget
The label and ttk::label widget gets a new attribute "-textangle". The argument "-textangle" is defined the same way as the canvas text item argument "-angle".
The definition is as follows:
-textangle rotationDegrees
RotationDegrees tells how many degrees to rotate the text anticlockwise about the positioning point for the text; it may have any floating-point value from 0.0 to 360.0. For example, if rotationDegrees is 90, then the text will be drawn vertically from bottom to top. This option defaults to 0.0.
This option does not has any influence of the placement of an eventual image. It does not rotate the whole label, but only the text.
The label option -wraplength is applied to label's text before rotation.
In the case of text only labels, where the width is specified in characters and the height in lines, the option -width applied to labels as if the option -textangle is zero. The same applies for the tk label and the -height option. In the case of the tk label, if both -width and -height options are different from zero, then the required space will rotate with the text. This is useful for 90° and 270° angles, to get a consistent text to required space ratio.
ttk style option
The ttk style option "-textangle" is added to the text and label elements. Any composite widget using those elements feature the new functionality.
An example are the tabs of the ttk::notebook widget.
Examples
label widget with 90 degrees rotated text
label .l1 -text "label" -textangle 90
ttk::label widget with 90 degrees rotated text
ttk::label .l2 -text "ttk::label" -textangle 90
ttk::notebook with tabs on top with 90° rotated text
The pages show the rotated labels from the upper examples.
ttk::style configure LTab.TNotebook.Tab -textangle 90
pack [ttk::notebook .n -style LTab.TNotebook] -fill both -expand true -padx 10 -pady 10
label .n.l1 -text label -textangle 90
.n add .n.l1 -text 1:label
ttk::label .n.l2 -text ttk::label -textangle 90
.n add .n.l2 -text 2:ttk::label
ttk::notebook with rotated tabs on the left side
Add the following as first line in the upper example:
ttk::style configure LTab.TNotebook -tabposition ws -tabplacement se
ttk::notebook with rotated tabs on the right side
Change the first line to:
ttk::style configure LTab.TNotebook -tabposition es -tabplacement sw
ttk::notebook with rotated tabs on the bottom side
Change the first line to:
ttk::style configure LTab.TNotebook -tabposition sw
Reference Implementation
The implementation is in Tk branch tip-751-labels-rotated-text.
It is the code of Tk ticket 23f52946, which is Emilianos code passed by AndroWish.
Emilianos original branch is label-angle-text.
Credits
The implementation and description is by Emiliano, Christian and Csaba. And I hope, I can credit someone for the tests. . Details are in Tk ticket 23f52946.
Backwards Compatibility
Abreviations for the present "-text" option does not work any more for the label and ttk::label widget.
Discussion
Buttons
Buttons are not supported as buttons with rotated text are a bad user interface design. However, angled text can be applied to ttk buttons through the use of styles.
Copyright
This document has been placed in the public domain.