Tryst::Window
Inherits Tryst::UI::WindowContract < Struct < Value < Object
A single toplevel window, addressed by its Tk path - the window-scoped
counterpart to the future Widget (which covers any widget of any
type). Groups every wm subcommand alongside composite
window-lifecycle behaviors (on_close, grab_set/grab_release, modal).
App's own window_title/set_window_title/show/hide convenience methods
delegate here internally.
ruby-tryst also has a Tryst::Wm shim (lib/tryst/wm.rb) wrapping the same handful of subcommands as window: keyword arguments instead. Not ported: it's a second spelling of what this class already is, nothing in ruby-tryst's own samples or gemba calls it, and a new subcommand would have to be written twice. Reach these through app.window(path).
@see https://www.tcl-lang.org/man/tcl9.0/TkCmd/wm.htm wm @see https://www.tcl-lang.org/man/tcl9.0/TkCmd/grab.htm grab
Constructors
Instance methods
The width/height ratio range the window manager will hold this window within, as {min_numer, min_denom, max_numer, max_denom}, or nil when no aspect constraint is set.
One window-manager attribute, e.g. attribute("-fullscreen"). Give name with its leading dash, the way Tcl spells it.
Returns the raw Tcl string: which attributes exist is platform-dependent, and their values are heterogeneous (-fullscreen is a boolean, -alpha a float, -type a name), so there's no single typed return to give. Coerce at the call site - Tryst.tcl_to_bool for the boolean ones.
Removes an aspect constraint set by #set_aspect. Tk spells this as the same subcommand with four EMPTY arguments rather than a separate one, which is not guessable from the getter/setter pair - hence its own method instead of nilable #set_aspect arguments.
Sets the window's geometry (e.g. "400x300", "400x300+100+50").
Release a grab previously set with #grab_set. Safe to call even if the window never held the grab - Tk itself treats that as a no-op.
Set the input grab on the window - while held, mouse and keyboard
events outside it (and its descendants) are redirected to it, the
building block #modal uses. grab is its own Tcl command family,
separate from wm. global: a global grab blocks input to every
other application too, not just this one - almost never what you
want; local (the default) is scoped to this application.
The largest size the window manager will let the user drag this window to, as {width, height} in pixels.
The smallest size the window manager will let the user drag this window to, as {width, height} in pixels.
Make the window modal: grabs input and sets focus on it immediately. Release it explicitly with #grab_release (typically from the window's own dismiss/close handling) when the dialog is done - the grab is NOT released automatically just because this method returns, since a modal dialog is meant to stay grabbed for its whole visible lifetime, not just its setup.
Two safety nets guard against a stuck grab locking out the rest of the display: if the window is destroyed while still grabbed (a crash mid-modal, or just forgetting to call #grab_release first), a <Destroy> binding releases it; if the optional setup block itself raises, the grab is released immediately rather than left dangling on a half-shown dialog.
Register a handler for the window manager's close button (WM_DELETE_WINDOW - the titlebar close box, Cmd-W, Alt-F4, etc., depending on platform).
Tk's own default behavior (destroy the window) only applies when nothing else has claimed this protocol - setting a handler here replaces it, so the block is entirely responsible for deciding whether the window actually closes. Call App#destroy yourself if you want it to; do nothing (or show a confirmation first) if you don't.
Whether the window manager has been told to skip this window entirely - no titlebar, no border, no decoration. What a tooltip or a custom-drawn popup wants.
Constrains the window's width/height ratio to between min_numer/min_denom and max_numer/max_denom.
Sets one window-manager attribute. A Bool is converted to Tk's own 0/1 spelling; anything else is stringified as-is.
Sets the maximum size. A very large value (Tk's own default) clears the constraint in practice.
Sets the minimum size. (0, 0) clears the constraint.
width/height: whether to allow resizing in that direction.
How the window manager is currently showing this window - "normal", "withdrawn", "iconic", "icon", or (Windows only) "zoomed". Left as a String rather than an enum: the set is platform-dependent, and every caller compares against one specific value anyway.
The window this one is a transient of (a subordinate the window manager keeps above its master, usually skipping the taskbar), or nil when it isn't transient to anything.
Makes this window transient to master (a path String or a Window). An empty string detaches it again.