Tryst::Widget
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
Instance methods
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".
Bind an event on this widget. See App#bind.
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
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)"
Register a handler for this window's close button (WM_DELETE_WINDOW). Meant for toplevels; see Window#on_close for the full behavior.
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.