struct

Tryst::Widget

Inherits Struct < Value < Object

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 (and Widget being a member of TclArgValue, so it can be passed directly as a #command arg/kwarg value too).

Created via App#create_widget.

@example btn = app.create_widget("ttk::button", text: "Click") btn.command(:configure, text: "Updated") app.command(:pack, btn, pady: 10) # to_s makes this work btn.destroy

Constructors

new(app : App, path)
Source

Instance methods

==(other : Widget) : Bool

Two widgets are the same widget when they address the same Tk path. Comparing against anything else is a compile error - to test a path, say so: widget.path == ".entry".

Source
bind(event : EventArg, *, subs : SubsArg = nil, &block : Array(String), CallbackSignal -> Nil) : String

Bind an event on this widget. See App#bind.

Source
command(*args : TclArgValue, **kwargs) : String

Invoke a widget subcommand. Prepends the widget path as the Tcl command.

@example btn.command(:configure, text: "New") # => .ttkbutton1 configure -text {New} btn.command(:invoke) # => .ttkbutton1 invoke

Source
destroy

Destroy this widget and all its children.

Source
exist?

Whether this widget still exists in the Tk interpreter.

Source
grab_release

Release a grab previously set on this window. See Window#grab_release.

Source
grab_set(global : Bool = false) : Nil

Grab input on this window. See Window#grab_set.

Source
grid

Grid this widget.

Source
hash(hasher)

See Object#hash(hasher)

Source
height

Current height in pixels.

Source
inspect(io : IO) : Nil

Appends this struct's name and instance variables names and values to the given IO.

struct Point
  def initialize(@x : Int32, @y : Int32)
  end
end

p1 = Point.new 1, 2
p1.to_s    # "Point(@x=1, @y=2)"
p1.inspect # "Point(@x=1, @y=2)"
Source
on_close

Register a handler for this window's close button (WM_DELETE_WINDOW). Meant for toplevels; see Window#on_close for the full behavior.

Source
pack

Pack this widget.

Source
path
Source
to_s(io : IO) : Nil

Same as #inspect(io).

Source
unbind(event : EventArg) : Nil

Remove an event binding from this widget. See App#unbind.

Source
width

Current width in pixels.

Source
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.

Source