Updated 2017-02-28 17:14:16 by bll

Tk differences on Mac OS X  edit

A collection of differences between Tk on Mac OS X as compared to Linux/Windows. Some of these are normal differences, some are non-issues, some are bugs.

Some of these differences are only found in the aqua theme and are (or should be) noted as such.

These are differences that will require an if statement to check if the code is running on the Mac OS X platform or if the aqua theme is in use.

Hopefully this will be helpful to anyone porting their Tk code across platforms.

Foreground and Background Colors

(Normal Difference)

Aqua theme: There is a limited set of colors that can be used. Widgets generally cannot have their foreground and background colors set.

If you need to set foreground or background colors, use the non-ttk widgets or use a non-aqua theme.

See the colors manual page for a list of Mac OS X colors.

label vs ttk::label


Fixed by Kevin Walzer, version 8.6.6

label includes a large amount of x padding that cannot be removed.
package require Tk
frame .f -background cyan
pack .f
label .la -text hello
ttk::label .lb -text hello
pack .la -in .f
pack .lb -in .f

More label/color issues

(Needs verification. Is systemTransparent a valid background?)

Create a label with a standard Mac OS X background:
label .l -background systemTransparent

Resizing the window and the label loses the background.

Switching a window to fullscreen mode

(Normal Difference)

To switch a window to fullscreen mode, the window must first be withdrawn.
      # For Linux/Mac OS X:

      set cfs [wm attributes $w -fullscreen]
      if { $::tcl_platform(os) eq "Darwin" } {
        if { $cfs == 0 } {
          # optional: save the window geometry
          set savevar [wm geometry $w]
        wm withdraw $w
      wm attributes $w -fullscreen [expr {1-$cfs}]
      if { $::tcl_platform(os) eq "Darwin" } {
        wm deiconify $w
        if { $cfs == 1 } {
          after idle [list wm geometry $w $savevar]

ttk::scrollbar Styling


Aqua theme: Any use of the -style command with ttk::scrollbar will revert the scrollbar to a non-aqua themed scrollbar. This change cannot be undone.

Localization of standard directory names

(Normal Difference)

Mac OS X uses an unusual method to localize the standard directory names (e.g. Music, Downloads), and a standard glob will pick up the non-localized name. The standard Mac OS X file and directory dialogs will localize the names.

Filesystem names and unicode

(Normal Difference)

Mac OS X stores the filenames in the filesystem as decomposed UTF-8 (NFD). If there is a need to display the filename to the user, the filename can be converted using Tcllib utilities or iconv.
# given a file with a list of decomposed filenames in it...
# iconv does not handle really long lines well, so be sure to put some newlines in.
set convertedoutput [exec iconv -c -f UTF-8-MAC -t UTF-8 $fn]



The Tk menu command is hooked into the Mac OS X global menubar. If you want a menu without using the global menubar, you will have to write your own top level menu.

Font sizing


Point sized fonts on Mac OS X are not sized properly. A 72 point font is usually 1 inch (2.54 cm) from the bottom descender to the top ascender. On Mac OS X, a 72 point font appears to also include the line spacing above the font.

Font scaling


tk scaling may (*) affect the sizing of fonts specified in points and not the fonts specified in pixels. On Mac OS X, this is backwards. In no situation should a font specified in pixels change sizes when there is a change in tk scaling.

(*) If the computer has the actual screen size configured, it may keep a font size in points set to its proper size.

ttk::entry and ttk::spinbox field background


Specifying -background for a ttk::entry or ttk::spinbox field on Mac OS X will change the field background color, not the background color. As is usual, the background color for the aqua theme is not changeable.

Arabic Language input and displaying in Tk works properly on Mac OS since version 10.9 and Windows Xp and above

On FreeBSD and Linux , Arabic does not work properly. I made this dirty solution : http://wiki.tcl.tk/39542 As long as it's fixed on Mac, I just really need to see it working on Linux and FreeBSD.