wish(1)

๐Ÿ“ฆ
version 8.6.18 ยท 2 versions
, in ubuntu questing, ubuntu resolute, ubuntu stonking

๐ŸŽ€ wish(1) ๐ŸŽ€ Tk Applications ๐Ÿ’–

โœจ NAME โœจ

wish โ€” simple windowing shell ๐Ÿฆ‹

๐Ÿ’… SYNOPSIS โœจ

wish ?options? ?fileName arg ...?

๐ŸŒธ OPTIONS ๐ŸŒธ

  • -encoding name โ€” okay so this sets the encoding of the text inside fileName. It only works if you put it before the fileName argument ๐Ÿ™ˆ
  • -colormap new โ€” gives your window its own brand-new private colormap instead of borrowing the screen's default one ๐ŸŒˆ
  • -display display โ€” picks the display (and screen) where the window shows up ๐Ÿ–ฅ๏ธโœจ
  • -geometry geometry โ€” the starting geometry for the window. If you set this, the value gets saved in the geometry global variable of the app's Tcl interpreter ๐Ÿ“๐Ÿ’œ
  • -name name โ€” the title shown in the window, AND the interpreter name that send commands use. Two jobs, one name, iconic ๐Ÿ‘‘
  • -sync โ€” runs every X server command synchronously so errors pop up immediately. It's way slower, but it's literally a lifesaver for debugging ๐Ÿ˜ญ๐Ÿ”ฅ
  • -use id โ€” embeds the app's main window inside the window with identifier id, instead of making it its own independent toplevel. id has to be written the same way as the -use value for toplevel widgets (so it looks like what winfo id returns) ๐Ÿฆ‹
โš ๏ธ Heads up bestie: on some platforms this only works properly if id is a Tk frame or toplevel with its -container option turned on.
  • -visual visual โ€” picks the visual for the window. visual can be any of the forms that the Tk_GetVisual procedure supports ๐ŸŽจ
  • -- โ€” passes every remaining argument straight through to the script's argv variable without trying to interpret them. This is how you hand stuff like -name to your script instead of letting wish eat it ๐Ÿซถ

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

Okay so wish is a simple program made of the Tcl command language, the Tk toolkit, and a main program that reads commands from standard input or from a file ๐Ÿ’–. It creates a main window and then processes Tcl commands like a queen ๐Ÿ‘‘. If you launch wish with arguments, the first few arguments, ?-encoding name? ?fileName?, tell it the name of a script file and, optionally, the encoding of the text stored in that file ๐Ÿ“œ. A value for fileName gets recognized as long as the argument doesn't start with โ€œ-โ€.

If there are no arguments, or the arguments don't specify a fileName, wish reads Tcl commands interactively from standard input ๐Ÿ’ฌ. It keeps going until all windows have been deleted or until end-of-file hits on standard input. If there's a file .wishrc in the user's home directory, wish evaluates it as a Tcl script right before reading the first command from standard input ๐ŸŒ™.

If your arguments DO specify a fileName, that file is treated as a script. Wish evaluates the script in fileName (which presumably builds a user interface โœจ), then responds to events until all windows have been deleted. Commands will NOT be read from standard input in this case ๐Ÿ™…โ€โ™€๏ธ. There's no automatic evaluation of .wishrc when you pass a script file on the wish command line, but the script can always source it if it wants to ๐Ÿซถ.

Note that on Windows, the wishversion.exe program is different from tclshversion.exe in one more important way: it doesn't connect to a standard Windows console and is a windowed program instead ๐ŸชŸ. Because of that, it also gets access to its own console command ๐Ÿ’ปโœจ.

๐Ÿงš OPTION PROCESSING ๐Ÿงš

Wish automatically handles all of the command-line options listed in the OPTIONS summary above ๐Ÿ’…. Any other command-line arguments are passed through to your application using the argc and argv variables described later ๐ŸŽ€.

๐ŸŒˆ APPLICATION NAME AND CLASS ๐ŸŒˆ

The application's name (used for things like send commands) comes from the -name option if you set it ๐Ÿ’œ. Otherwise it's taken from fileName if that's specified, or from the command name you used to invoke wish ๐Ÿฆ‹. In those last two cases, if the name contains a โ€œ/โ€ character, only the characters after the last slash count as the application name โœ‚๏ธ.

The class of the application (used for stuff like setting options with a RESOURCE_MANAGER property or a .Xdefaults file) is the same as its name, except the first letter gets capitalized ๐Ÿ’–.

๐Ÿ”ฎ VARIABLES ๐Ÿ”ฎ

Wish sets the following global Tcl variables ๐Ÿ‘‘:

  • argc โ€” the count of the number of arg arguments (0 if there are none), not counting the options described above ๐Ÿ”ข.
  • argv โ€” a Tcl list of the arg arguments that follow a -- option or don't match any of the options listed in OPTIONS above, in order. If there are no such arguments, it's an empty string ๐Ÿ“‹.
  • argv0 โ€” holds fileName if it was specified. Otherwise it holds the name you used to invoke wish ๐Ÿท๏ธ.
  • geometry โ€” if you used the -geometry option, wish copies its value into this variable. If the variable still exists after fileName has been evaluated, wish uses its value in a wm geometry command to set the main window's geometry ๐Ÿ“โœจ.
  • tcl_interactive โ€” equals 1 if wish is reading commands interactively (no fileName was given and standard input is a terminal-like device), and 0 otherwise ๐Ÿ–ฅ๏ธ.

๐Ÿ“œ SCRIPT FILES ๐Ÿ“œ

Here's a vibe: if you write a Tcl script in a file whose first line is

#!/usr/local/bin/wish

then you can run the script file directly from your shell, as long as you mark it as executable ๐Ÿƒโ€โ™€๏ธ๐Ÿ’จ. This assumes wish was installed in the default location, /usr/local/bin. If it's installed somewhere else, you'll need to edit that line to match ๐Ÿ™ˆ. Many UNIX systems won't let the #! line go over about 30 characters, so make sure the wish executable can be reached with a short file name ๐Ÿ“.

An even better approach (lowkey the main character move ๐Ÿ‘‘) 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 big advantages over the one in the previous paragraph ๐Ÿ”ฅ. First, the location of the wish binary doesn't get hard-wired into the script: it can live anywhere on your shell search path ๐Ÿ—บ๏ธ. Second, it gets around the 30-character file name limit from before ๐Ÿ™Œ. Third, it works even if wish is itself a shell script (some systems do this to handle multiple architectures or operating systems, where the wish script picks one of several binaries to run ๐Ÿงฉ). The three lines get both sh and wish to process the script, but only sh actually runs the exec. sh goes first: it treats the second line as a comment and runs the third line. The exec statement makes the shell stop processing and start up wish to reprocess the entire script ๐Ÿ”. When wish starts, it treats all three lines as comments, because the backslash at the end of the second line makes the third line part of that comment ๐Ÿ’€.

The end of a script file can be marked either by the physical end of the medium, or by the character โ€œ\032โ€ (โ€œ\u001aโ€, control-Z) ๐Ÿ”š. If that character is in the file, the wish application reads text up to but NOT including it ๐Ÿ™…โ€โ™€๏ธ. An app that needs this character inside the file can encode it as โ€œ\032โ€, โ€œ\x1aโ€, or โ€œ\u001aโ€, or generate it with commands like format or binary ๐Ÿงช.

๐Ÿ’ฌ PROMPTS ๐Ÿ’ฌ

When wish is invoked interactively, it normally prompts for each command with โ€œ% โ€ ๐Ÿ’…. You can change the prompt by setting the variables tcl_prompt1 and tcl_prompt2. If tcl_prompt1 exists, it must be a Tcl script that outputs a prompt; instead of outputting a prompt, wish evaluates the script in tcl_prompt1 ๐Ÿช„. The variable tcl_prompt2 works similarly when you hit newline but the current command isn't complete yet. If tcl_prompt2 isn't set, no prompt is output for incomplete commands ๐ŸŒธ.

๐Ÿ”— SEE ALSO ๐Ÿ”—

tclsh(1), toplevel(n), Tk_Main(3), Tk_MainLoop(3), Tk_MainWindow(3) ๐Ÿ“š๐Ÿ’–

๐Ÿท๏ธ KEYWORDS ๐Ÿท๏ธ

application, argument, interpreter, prompt, script file, shell, toolkit, toplevel ๐Ÿซง


Tk 8.0 ยท wish(1) ยท all done bestie ๐Ÿซถ๐Ÿ’–โœจ

๐Ÿ“ฆ where this page comes from