Teek::Widget Class
Thin wrapper around a Tk widget path. Holds a reference to the App and the widget’s Tcl path string.
Instances are interchangeable with plain strings anywhere a widget path
is expected thanks to #to_s returning the path.
Created via App#create_widget:
Inherits: Object
Instance Methods ↑
bind(event, *subs, &block)
Bind an event on this widget.
Parameters
eventString— Tk event namesubsArray<Symbol, String>— substitution codes
Returns void
@yield called when the event fires
See also
command(*args, **kwargs)
Invoke a widget subcommand. Prepends the widget path as the Tcl command.
Parameters
args— positional argumentskwargs— keyword arguments mapped to -key value pairs; any Proc value (e.g. command:) is tracked and released if reconfigured or when this widget is destroyed
Returns String — the Tcl result
Example
btn.command(:configure, text: 'New') # => .ttkbutton1 configure -text {New}
btn.command(:invoke) # => .ttkbutton1 invoke
grab_set(global: false)
Grab input on this window. See Window#grab_set.
Parameters
globalBoolean
Returns void
grid(**kwargs)
Grid this widget.
Parameters
kwargs— options passed to the Tk grid command
Returns self
initialize(app, path)
Returns Widget — a new instance of Widget
modal(global: false, &block)
Make this window modal. See Window#modal.
Parameters
globalBoolean
Returns void
@yield optional - runs with the grab and focus already set
on_close(&block)
Register a handler for this window’s close button (WM_DELETE_WINDOW).
Meant for toplevels; see Window#on_close for the full behavior.
Returns void
@yield called when the window's close button is pressed
See also
pack(**kwargs)
Pack this widget.
Parameters
kwargs— options passed to the Tk pack command
Returns self
to_s
Returns String — the Tcl widget path
unbind(event)
Remove an event binding from this widget.
Parameters
eventString— Tk event name
Returns void
See also
window
This widget as a Window - the window-scoped counterpart covering
wm subcommands and composite behaviors (on_close, grab_set/
grab_release, modal). Meant for toplevels.
Returns Window
Attributes ↑
app [R]
Returns the value of attribute app.
path [R]
Returns the value of attribute path.