struct

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

new(app : App, path)
Source

Instance methods

aspect

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.

Source
attribute(name : String) : String

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.

Source
clear_aspect

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.

Source
deiconify

Show the window (map it if withdrawn/iconified).

Source
geometry

Geometry string (e.g. "400x300+0+0").

Source
geometry=(value : String) : Nil

Sets the window's geometry (e.g. "400x300", "400x300+100+50").

Source
grab_release

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.

Source
grab_set(global : Bool = false) : Nil

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.

Source
iconify

Shrink the window to its icon. The counterpart to #deiconify.

Source
maxsize

The largest size the window manager will let the user drag this window to, as {width, height} in pixels.

Source
minsize

The smallest size the window manager will let the user drag this window to, as {width, height} in pixels.

Source
on_close

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.

Source
overrideredirect=(value : Bool) : Nil
Source
overrideredirect?

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.

Source
path
Source
resizable

{width_resizable, height_resizable}.

Source
set_aspect(min_numer : Int32, min_denom : Int32, max_numer : Int32, max_denom : Int32) : Nil

Constrains the window's width/height ratio to between min_numer/min_denom and max_numer/max_denom.

Source
set_attribute(name : String, value : String | Bool | Int32 | Float64) : Nil

Sets one window-manager attribute. A Bool is converted to Tk's own 0/1 spelling; anything else is stringified as-is.

Source
set_maxsize(width : Int32, height : Int32) : Nil

Sets the maximum size. A very large value (Tk's own default) clears the constraint in practice.

Source
set_minsize(width : Int32, height : Int32) : Nil

Sets the minimum size. (0, 0) clears the constraint.

Source
set_resizable(width : Bool, height : Bool) : Nil

width/height: whether to allow resizing in that direction.

Source
state

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.

Source
title

The window's current title.

Source
title=(value : String) : Nil

Sets the window's title.

Source
to_s(io : IO) : Nil

Same as #inspect(io).

Source
transient

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.

Source
transient=(master) : Nil

Makes this window transient to master (a path String or a Window). An empty string detaches it again.

Source
withdraw

Hide the window without destroying it.

Source