The list of Tk widgets

Here is an attempt to write a script to display each widget available in Tk. It made the assumption that all widgets begin with a lowercase letter. But this assumption seems not valid as for instance ttk::deprecated is not a widget at all or clipboard is not listed.

 #
 # the dynamic list of Tk widgets
 # 

 puts " Tk version [package require Tk]"
 puts " ----"

 set tkCommands [lsort [info commands "::tk::\[a-z\]*"]] 

 foreach cmd $tkCommands { 
         puts [string range $cmd 6 end]
 }

 exit 

It gives :

 Tk version 8.5.7
 ----
 button
 canvas
 checkbutton
 entry
 frame
 label
 labelframe
 listbox
 mc
 mcmax
 mcmaxamp
 menubutton
 message
 panedwindow
 radiobutton
 scale
 scrollbar
 spinbox
 text
 toplevel

It works only with version 8.5 so far.


JH This completely misses the themed Tk widget set (::ttk::*).


LGT This script tries to correct this :

        #
        # the dynamic list of Tk widgets
        #

        puts " Tk version [package require Tk]"
        puts " ----"

        set tkCommands [lsort [info commands "::tk::\[a-z\]*"]]
        set ttkCommands [lsort [info commands "::ttk::\[a-z\]*"]]

        set allCommands [concat $tkCommands $ttkCommands]

        foreach cmd $allCommands {
                puts [string range $cmd 2 end]
        }

        exit 

It gives :

         Tk version 8.5.7
         ----
        tk::button
        tk::canvas
        tk::checkbutton
        tk::entry
        tk::frame
        tk::label
        tk::labelframe
        tk::listbox
        tk::mc
        tk::mcmax
        tk::mcmaxamp
        tk::menubutton
        tk::message
        tk::panedwindow
        tk::radiobutton
        tk::scale
        tk::scrollbar
        tk::spinbox
        tk::text
        tk::toplevel
        ttk::button
        ttk::checkbutton
        ttk::clickToFocus
        ttk::combobox
        ttk::copyBindings
        ttk::cursor
        ttk::deprecated
        ttk::deprecated'warning
        ttk::do'deprecate
        ttk::entry
        ttk::focusFirst
        ttk::frame
        ttk::globalGrab
        ttk::grabWindow
        ttk::label
        ttk::labelframe
        ttk::menubutton
        ttk::notebook
        ttk::paned
        ttk::panedwindow
        ttk::progressbar
        ttk::radiobutton
        ttk::releaseGrab
        ttk::scale
        ttk::scrollbar
        ttk::separator
        ttk::setCursor
        ttk::setTheme
        ttk::sizegrip
        ttk::style
        ttk::takefocus
        ttk::takesFocus
        ttk::themes
        ttk::traverseTo
        ttk::treeview

Here is another attempt, which misses also ttk:: commmands, but not clipboard command and seems closer to documentation commands list :

        #
        # the dynamic list of Tk commands
        #
        set tclCommands [lsort [info commands]]
        puts "[llength $tclCommands] tcl commands."

        set tkVersion [package require Tk]

        set allCommands [lsort [info commands]]

        puts "[llength $allCommands] tcl and tk ($tkVersion) commands."
        set tkCommands {}

        foreach element $allCommands {
                if { [lsearch $tclCommands $element] < 0 } {
                        lappend tkCommands $element
                } 
        }

        foreach cmd $tkCommands {
                puts $cmd
        }

        exit 

It gives :

        92 tcl commands.
        152 tcl and tk (8.5.7) commands.
        .
        auto_mkindex
        auto_mkindex_old
        auto_reset
        bell
        bind
        bindtags
        button
        canvas
        checkbutton
        clipboard
        destroy
        entry
        event
        focus
        font
        frame
        grab
        grid
        image
        label
        labelframe
        listbox
        lower
        menu
        menubutton
        message
        option
        pack
        panedwindow
        pkg_mkIndex
        place
        radiobutton
        raise
        registry
        scale
        scrollbar
        selection
        spinbox
        tclPkgSetup
        tclPkgUnknown
        tcl_findLibrary
        text
        thread_load
        thread_source
        tk
        tk_chooseColor
        tk_chooseDirectory
        tk_getOpenFile
        tk_getSaveFile
        tk_menuSetFocus
        tk_messageBox
        tk_popup
        tk_textCopy
        tk_textCut
        tk_textPaste
        tkwait
        toplevel
        winfo
        wm