wish(1)
wish(1) โ the Tk Applications manual, but make it make sense ๐
okay bestie, sit down, hydrate, because this is the page for wish โ the simple windowing shell from the Tk Applications section of the manual. she's been around since Tk 8.0 and she's still serving. no cap. โจ
โจ NAME โจ
wish โ simple windowing shell ๐ช๐ซถ
๐ธ SYNOPSIS ๐ธ
wish ?options? ?fileName arg ...?
๐ OPTIONS ๐
-encodingname โ tells her what encoding the text in fileName is in. heads up though: this one is only recognized before the fileName argument. so like, order matters, queen. ๐-colormapnew โ says the window should get its own brand-new private colormap instead of vibing with the default colormap for the screen.-displaydisplay โ the display (and screen) to put the window on.-geometrygeometry โ the initial geometry for the window. if you pass this, its value gets stored in thegeometryglobal variable of the application's Tcl interpreter. iykyk.-namename โ uses name as the title shown in the window, and as the interpreter's name forsendcommands.-syncโ executes all X server commands synchronously so errors get reported immediately. it is so much slower, but it's genuinely useful for debugging. ๐-useid โ says the application's main window should be embedded in the window whose identifier is id, instead of being created as an independent toplevel window. id has to be specified the same way as the value for the-useoption for toplevel widgets (i.e. it has a form like the one returned by thewinfo idcommand).
ngl, on some platforms this only works correctly if id refers to a Tk frame or toplevel that has its -container option enabled.
-visualvisual โ the visual to use for the window. visual can have any of the forms supported by theTk_GetVisualprocedure.--โ passes all the remaining arguments through to the script'sargvvariable without interpreting them. it's the little mechanism that lets you pass things like-nameto a script instead of havingwisheat them herself. iconic behavior honestly. ๐
๐ฆ DESCRIPTION ๐ฆ
wish is a simple program made of three things: the Tcl command language, the Tk toolkit, and a main program that reads commands from standard input or from a file. she creates a main window and then justโฆ processes Tcl commands. main character energy. ๐
if wish is invoked with arguments, then the first few arguments โ ?-encoding name? ?fileName? โ specify the name of a script file and, optionally, the encoding of the text data stored in that script file. a value for fileName is recognized if the appropriate argument does not start with โ-โ.
if there are no arguments, or the arguments don't specify a fileName, then wish reads Tcl commands interactively from standard input. she keeps processing commands until all windows have been deleted or until end-of-file is reached on standard input. and if there's a file .wishrc in the user's home directory, wish evaluates that file as a Tcl script just before reading the first command from standard input. so cute. ๐ง
if the arguments to wish do specify a fileName, then fileName is treated as the name of a script file. wish will evaluate the script in fileName (which presumably creates a user interface), then respond to events until all windows have been deleted. commands will not be read from standard input in this case. and listen โ there is no automatic evaluation of .wishrc when a script file name shows up on the wish command line. the script file can always source it if it wants to, though. ๐
heads up on Windows: thewishversion.exeprogram differs from thetclshversion.exeprogram in one more important way โ it does not connect to a standard Windows console, and is instead a windowed program. because of that, it additionally provides access to its ownconsolecommand.
๐ OPTION PROCESSING ๐
wish automatically processes all of the command-line options described in the OPTIONS summary above. any other command-line arguments besides these get passed through to the application using the argc and argv variables described later. periodt.
๐ APPLICATION NAME AND CLASS ๐
the name of the application, which is used for things like send commands, comes from the -name option if it's specified. otherwise it comes from fileName, if that's specified, or from the command name by which wish was invoked. in those last two cases, if the name contains a โ/โ character, then only the characters after the last slash get used as the application name. slay, path handling. โ๏ธ
the class of the application โ used for things like specifying options with a RESOURCE_MANAGER property or .Xdefaults file โ is the same as its name, except the first letter is capitalized. ๐
โญ VARIABLES โญ
wish sets the following global Tcl variables:
argcโ a count of the number of arg arguments (0if none), not including the options described above.argvโ a Tcl list whose elements are the arg arguments that follow a--option or that don't match any of the options in OPTIONS above, in order. or an empty string if there are no such arguments.argv0โ contains fileName if it was specified. otherwise, contains the name by whichwishwas invoked.geometryโ if the-geometryoption is specified,wishcopies its value into this variable. if the variable still exists after fileName has been evaluated,wishuses the value of the variable in awm geometrycommand to set the main window's geometry.tcl_interactiveโ contains1ifwishis reading commands interactively (fileName was not specified and standard input is a terminal-like device),0otherwise.
๐ SCRIPT FILES ๐
if you create a Tcl script in a file whose first line is
#!/usr/local/bin/wish
then you can invoke the script file directly from your shell if you mark it as executable. ๐ซถ this assumes wish has been installed in the default location in /usr/local/bin; if she lives somewhere else, you'll have to modify that line to match. also, many UNIX systems don't allow the #! line to exceed about 30 characters in length, so be sure the wish executable can be accessed with a short file name. ๐
an even better approach is to start your script files with these three lines:
#!/bin/sh
# the next line restarts using wish \
exec wish "$0" ${1+"$@"}
this approach has three advantages over the approach in the previous paragraph:
- the location of the
wishbinary doesn't have to be hard-wired into the script โ it can be anywhere in your shell search path. - it gets around the 30-character file name limit from the previous approach.
- it works even if
wishis itself a shell script (some systems do this in order to handle multiple architectures or operating systems: thewishscript selects one of several binaries to run).
the three lines cause both sh and wish to process the script, but the exec is only executed by sh. sh processes the script first; it treats the second line as a comment and executes the third line. the exec statement causes the shell to stop processing and instead start up wish to reprocess the entire script. when wish starts up, it treats all three lines as comments, since the backslash at the end of the second line causes the third line to be treated as part of the comment on the second line. chef's kiss, honestly. ๐ญโจ
the end of a script file may be marked either by the physical end of the medium, or by the character โ\032โ (โ\u001aโ, control-Z). if this character is present in the file, the wish application will read text up to but not including the character. an application that requires this character in the file may encode it as โ\032โ, โ\x1aโ, or โ\u001aโ; or may generate it by use of commands such as format or binary.
๐ PROMPTS ๐
when wish is invoked interactively, she normally prompts for each command with โ% โ. you can change the prompt by setting the variables tcl_prompt1 and tcl_prompt2. ๐ฅ
if the variable tcl_prompt1 exists, then it must consist of a Tcl script to output a prompt; instead of outputting a prompt, wish will evaluate the script in tcl_prompt1. the variable tcl_prompt2 is used in a similar way when a newline is typed but the current command is not yet complete; if tcl_prompt2 is not set, then no prompt is output for incomplete commands.
๐ธ ZIPVFS ๐ธ
when a zipfile is concatenated to the end of wish, on startup the contents of the zip archive will be mounted under the virtual file system //zipfs:/. if a top level directory tk_library is present in the zip archive, it will become the directory loaded as env(TK_LIBRARY). if a file named main.tcl is present in the top level directory of the zip archive, it will be sourced instead of the shell's normal command line handling. ๐ฎโ๐จ
only one zipfile can be concatenated to the end of the executable image (tclsh, or wish). however, if multiple zipfiles are concatenated, only the last one is used.
this filesystem is read-only. files cannot be added or modified within this mounted file system. see zipfs(n) for complete details.
๐ฆ SEE ALSO ๐ฆ
tclsh(1), toplevel(n), zipfs(n), Tk_Main(3), Tk_MainLoop(3), Tk_MainWindow(3)
๐ KEYWORDS ๐
application, argument, interpreter, prompt, script file, shell, toolkit, toplevel
and that's the whole vibe check, bestie. ๐ this one's from the Tk 8.0 era of the manual, filed under wish(1) in the Tk Applications corner of the docs โ so go forth and make windows, and remember: exec wish "$0" ${1+"$@"} is the moment. ๐ซถโจ๐
๐ฆ where this page comes from
- alpine 3.23: tk9-doc 9.0.3-r0 ยท TCL
- alpine 3.24: tk9-doc 9.0.3-r2 ยท TCL
- fedora 43: tk 1:9.0.2-1.fc43 ยท TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- fedora 43: tk 1:9.0.2-1.fc43 ยท TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- fedora 44: tk 1:9.0.2-1.fc44 ยท TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- fedora 44: tk 1:9.0.2-1.fc44 ยท TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- nixos 26.05: tk 9.0.3
- Copyright (c) 1991-1994 The Regents of the University of California
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms