Updated 2009-08-10 09:09:02 by peterc

Aqua is the name of the native MacOS X look.

Even with the help of tile, Tk applications do not yet look fully native out of the box. It is, however, possible to improve the look of the default widgets with careful settings. This page collects some of them:

  • White border around Tk widgets : Some Tk widgets that do not yet have a tile equivalent, such as tk_optionMenu, display a white border around them that make them stand out against regular OSX pinstripe background. It is possible to minimize this effect with : -borderwidth 0 -bg #ececec

Lars H: Does that address a different issue than that which is addressed by setting the -highlightbackground? Cf. discussion at the end of button.

  • Tile's scrollbars are not the Aqua ones, whereas recent versions of Tk without Tile use the native Aqua scrollbars. Why is this?

JH - See Aqua toplevels for some ideas to rework toplevel handling. On a semi-related note, check out Going Native with Komodo's GUI Builder, which has before and after pics of the aqua porting attempt.

MAK - The current architecture of the layout system isn't very conducive to it (yet). The problem is, Tile wants to be able to theme, draw and handle events for individual elements (e.g. the up arrow, the down arrow (of which there might be multiple), the slider, etc.), whereas the Appearance Manager (the Apple API for drawing control elements) doesn't factor things out that far. To draw a scrollbar with Appearance Manager, you call one API to draw the trough (which also draws the arrows) and one API to draw the slider; and it doesn't *actually* draw either of them until you call the APIs to draw both. The situation is similar with Qt, I hear. I don't know if Joe has a plan for how to deal with it or not yet, but I think (and I seem to recall him hinting that) the thing to do is probably to use the full Aqua scrollbar setup, and if you want to change any part of it you have to theme the whole thing, rather than just e.g. the arrows. But there are probably complications to deal with for event handling, since there's no "arrow" element to do bindings for. The combobox isn't perfect, either, for similar reasons.. In that case, there isn't even an Appearance Manager API to draw the right button shape for comboboxes, and there are problems with Tk's handling of wm overrideredirect and wm transient under Aqua (and, unfortunately, event handling for more appropriate Aqua-specific window styles). So "perfect" comboboxes under Aqua may have to use a complete Carbon control.

[GNJ] - Check out info on Daniel A. Steffen's (latest?) Tcl/Tk Aqua build at http://aspn.activestate.com/ASPN/Mail/Message/tcl-mac/3467338. Just had a play round and the inclusion of system colours, full transparency and the ability to change the root window style (metal etc) means Tk Osx just got several steps closer to Cocoa on looks, heres a dumb example to make custom shaped windows, notice the pinstrip background, and how the ugly border round buttons is gone, all in a few lines of code. See Daniel's post for a full list of major changes.

 # custom shaped windows
 ::tk::unsupported::MacWindowStyle style . document {noTitleBar}
 wm attribute . -transparent 1

 grid [canvas .t -width 200 -height 200 -highlightthickness 0]

 .t configure -background systemTransparent

 # the drop shadow only seems to appear when you click on another window then back at the moment
 .t create oval 0 0 150 150 -fill systemSheetBackground -outline systemSheetBackground

 # drag the window ala metal
 bind . <1> {set iX0 [expr %X-[winfo rootx .]]; set iY0 [expr (%Y-[winfo rooty .])]; set wMoved 0 }
 bind . <B1-Motion> { wm geometry . +[expr %X-$iX0]+[expr %Y-$iY0]; set wMoved 1 }
 bind . <ButtonRelease-1> { if { $wMoved } break }

 place [button .b -text cool!] -relx 0.25 -rely 0.3
 .b configure -highlightbackground systemSheetBackground

See also:

External links:

  • Apple's Human Interface Guidelines [1]
  • The Indie HIG [2] and its Wiki [3] tries to supplement Apple's Human Interface Guidelines and is a great resource for how UI elements should look like.

Category GUI Category Mac