Tcl 9.1/Tk9.1 Documentation > Tk Commands, version 9.1a1 > fileicon

Tcl/Tk Applications | Tcl Commands | Tk Commands | [incr Tcl] Package Commands | SQLite3 Package Commands | TDBC Package Commands | tdbc::mysql Package Commands | tdbc::odbc Package Commands | tdbc::postgres Package Commands | tdbc::sqlite3 Package Commands | Thread Package Commands | Tcl C API | Tk C API | [incr Tcl] Package C API | TDBC Package C API

NAME

fileicon — Platform-native icon image for file type/extension.

SYNOPSIS

tk fileicon file size

DESCRIPTION

The tk fileicon command creates a platform-specific file icon. Its intent is to provide a visual representation of a file type that is expected by users on that platform. The command takes two arguments - an aboslute file path and an icon size, which be any size (on Windows these map to the closest of 16, 32, 48 or 256 pixels because of API constraints).

EXAMPLE

Here is an example of the tk fileicon code:

set img [tk fileicon [file normalize text.txt] 32]
pack [label .l -text "text.txt" -image $img -compound top]

PLATFORM NOTES

On Windows and macOS, system API's are used; on X11, icons from the Tango project - the default icon theme for the Gnome desktop - are used.

KEYWORDS

image, icon
Copyright © 2025 Kevin Walzer.