Tk commands

As we mentioned in the introduction, STK can easily communicate with the Tk toolkitndexfile(index-entry "Tk toolkit" "rm" aux )ndexfile(index-entry "toolkit" "rm" aux ). All the commands defined by the Tk toolkit are visible as ndexfile(index-entry "Tk-command" "tt" aux )Tk-commands, a basic type recognized by the interpreter. ndexfile(index-entry "Tk-command" "tt" aux )Tk-commands can be called like regular scheme procedures, serving as an entry point into the Tk library. Note: Some ndexfile(index-entry "Tk-command" "tt" aux )Tk-commands can dynamically create other ndexfile(index-entry "Tk-command" "tt" aux )Tk-commands. For instance, execution of the expression $\Longrightarrow$
$\Longrightarrow$ unspecified error makeotherˆ`=̀13`


          gobblecr(label '.lab)  
will create a new ndexfile(index-entry "Tk-command" "tt" aux )Tk-command called ``.lab''. This new object, which was created by a primitive ndexfile(index-entry "Tk-command" "tt" aux )Tk-command, will be called a widgetndexfile(index-entry "widget" "rm" aux ).

Note: When a new widget is created, it captures its creation environment. This permits to have bindings which access variables in the scope of the widget creation call (see [*]).





`=̀13`(ndexfile(index-entry "tk-command?" "tt" main )tk-command?obj)
procedure
Returns #t if obj is a ndexfile(index-entry "Tk-command" "tt" aux )Tk-command, otherwise returns #f. $\Longrightarrow$
$\Longrightarrow$ unspecified error makeotherˆ`=̀13`


          gobblecr(tk-command? label) #t(begin (label '.lab) (tk-command? .lab)) #t(tk-command? 12) #f





`=̀13`(ndexfile(index-entry "widget?" "tt" main )widget?obj)
procedure
Returns #t if obj is a widget, otherwise returns #f. A widget is a ndexfile(index-entry "Tk-command" "tt" aux )Tk-command created by a primitive ndexfile(index-entry "Tk-command" "tt" aux )Tk-command such as ndexfile(index-entry "button" "tt" aux )button, ndexfile(index-entry "label" "tt" aux )label, ndexfile(index-entry "menu" "tt" aux )menu, etc. $\Longrightarrow$
$\Longrightarrow$ unspecified error makeotherˆ`=̀13`


          gobblecr(widget? label) #f(begin (label '.lab) (widget? .lab)) #t(widget? 12) #f





`=̀13`(ndexfile(index-entry "widget->string" "tt" main )widget->stringwidget)
procedure
Returns the widget name of widget as a string. $\Longrightarrow$
$\Longrightarrow$ unspecified error makeotherˆ`=̀13`


          gobblecr(begin (label '.lab) (widget->string .lab)) ".lab"





`=̀13`(ndexfile(index-entry "string->widget" "tt" main )string->widgetstr)
procedure
Returns the widget whose name is str if it exists; otherwise returns #f. $\Longrightarrow$
$\Longrightarrow$ unspecified error makeotherˆ`=̀13`


          gobblecr(begin (label '.lab) (string->widget ".lab")) the ndexfile(index-entry "Tk-command" "tt" aux )Tk-command named ".lab"





`=̀13`(ndexfile(index-entry "widget-name" "tt" main )widget-namewidget)
procedure
Returns the widget name of widget as a symbol. $\Longrightarrow$
$\Longrightarrow$ unspecified error makeotherˆ`=̀13`


          gobblecr(begin (label '.lab) (widget->name .lab)) .lab





`=̀13`(ndexfile(index-entry "set-widget-data!" "tt" main )set-widget-data!widget expr)
procedure
ndexfile(index-entry "Set-widget-data!" "tt" aux )Set-widget-data! associates arbitrary data with a widget. The system makes no assumptions about the type of expr; the data is for programmer convenience only. As shown below, it could be used as a kind of property list for widgets.





`=̀13`(ndexfile(index-entry "get-widget-data" "tt" main )get-widget-datawidget)
procedure
Returns the data previously associated with widget if it exists; otherwise returns #f. $\Longrightarrow$
$\Longrightarrow$ unspecified error makeotherˆ`=̀13`


          gobblecr(begin    (set-widget-data! .w '(:mapped #t :geometry "10x50"))   (get-keyword :mapped (get-widget-data .w))) #t