Table of Contents

Name

tkmacicon - Render platform-native icons on OS X

Synposis

package require tkmacicon

tkmacicon::geticonfrompath filepath? width? height? tkmacicon::geticonfrompath filetype? width? height?

Description

The tkmacicon package provides the data necessary to
platform-native icons on OS X as Tk images. The ::tkmacicon::geticonfrompath command takes three arguments: a file path, width, and height. The ::tkmacicon::geticonfromtype command takes three arguments: a file extension, width, and height. These commands provide the raw image data necessary to render a Mac icon as a native Tk image, like so:

image create photo icon -data [tkmacicon::geticonfrompath "/Users/username/Desktop/file.txt" 16 16]

image create photo icon -data [tkmacicon::geticonfromtype ".txt" 16 16]

Limitations

The tkmacicon package provides functionality similar to a core command in Tk’s Mac-Cocoa port, tk::mac::iconBitmap. The primary difference is that, for historical reasons,
tk::mac::iconBitmap returns a bitmap, and not all Tk widgets (especially the ttk themed widgets) can work with bitmaps. Internally, tkmacicon converts Mac icon data to PNG format, then returns that data as a base64-encoded string as data pass to the Tk "photo" command. In Tk 8.6, PNG’s are natively supported, but in Tk 8.5, the Img package must be present for tkmacicon to work.

Keywords

icon, Mac, Cocoa


Table of Contents