wish(1)
๐ 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 thegeometryglobal variable of the app's Tcl interpreter ๐๐-name nameโ the title shown in the window, AND the interpreter name thatsendcommands 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-usevalue for toplevel widgets (so it looks like whatwinfo idreturns) ๐ฆ
โ ๏ธ 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 theTk_GetVisualprocedure supports ๐จ--โ passes every remaining argument straight through to the script'sargvvariable without trying to interpret them. This is how you hand stuff like-nameto 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 (0if 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-geometryoption, wish copies its value into this variable. If the variable still exists after fileName has been evaluated, wish uses its value in awm geometrycommand to set the main window's geometry ๐โจ.tcl_interactiveโ equals1if wish is reading commands interactively (no fileName was given and standard input is a terminal-like device), and0otherwise ๐ฅ๏ธ.
๐ 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
- ubuntu questing: tk8.6 8.6.17-1
- ubuntu resolute: tk8.6 8.6.17-1build1
- ubuntu stonking: tk8.6 8.6.18-1
- Copyright (c) 1991-1994 The Regents of the University of California
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms