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 ๐Ÿ’…

  • -encoding name โ€” 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. ๐Ÿ‘‘
  • -colormap new โ€” says the window should get its own brand-new private colormap instead of vibing with the default colormap for the screen.
  • -display display โ€” the display (and screen) to put the window on.
  • -geometry geometry โ€” the initial geometry for the window. if you pass this, its value gets stored in the geometry global variable of the application's Tcl interpreter. iykyk.
  • -name name โ€” uses name as the title shown in the window, and as the interpreter's name for send commands.
  • -sync โ€” executes all X server commands synchronously so errors get reported immediately. it is so much slower, but it's genuinely useful for debugging. ๐Ÿ’€
  • -use id โ€” 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 -use option for toplevel widgets (i.e. it has a form like the one returned by the winfo id command).
ngl, on some platforms this only works correctly if id refers to a Tk frame or toplevel that has its -container option enabled.
  • -visual visual โ€” the visual to use for the window. visual can have any of the forms supported by the Tk_GetVisual procedure.
  • -- โ€” passes all the remaining arguments through to the script's argv variable without interpreting them. it's the little mechanism that lets you pass things like -name to a script instead of having wish eat 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: the wishversion.exe program differs from the tclshversion.exe program 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 own console command.

๐ŸŒˆ 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 (0 if 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 which wish was invoked.
  • geometry โ€” if the -geometry option is specified, wish copies its value into this variable. if the variable still exists after fileName has been evaluated, wish uses the value of the variable in a wm geometry command to set the main window's geometry.
  • tcl_interactive โ€” contains 1 if wish is reading commands interactively (fileName was not specified and standard input is a terminal-like device), 0 otherwise.

๐ŸŽ€ 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:

  1. the location of the wish binary doesn't have to be hard-wired into the script โ€” it can be anywhere in your shell search path.
  2. it gets around the 30-character file name limit from the previous approach.
  3. it works even if wish is itself a shell script (some systems do this in order to handle multiple architectures or operating systems: the wish script 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