1Tk_Init(3) Tk Library Procedures Tk_Init(3)
2
3
4
5______________________________________________________________________________
6
8 Tk_Init, Tk_SafeInit - add Tk to an interpreter and make a new Tk
9 application.
10
12 #include <tk.h>
13
14 int
15 Tk_Init(interp)
16
17 int
18 Tk_SafeInit(interp)
19
21 Tcl_Interp *interp (in) Interpreter in which to load
22 Tk. Tk should not already be
23 loaded in this interpreter.
24_________________________________________________________________
25
26
28 Tk_Init is the package initialization procedure for Tk. It is normally
29 invoked by the Tcl_AppInit procedure for an application or by the load
30 command. Tk_Init adds all of Tk's commands to interp and creates a new
31 Tk application, including its main window. If the initialization is
32 successful Tk_Init returns TCL_OK; if there is an error it returns
33 TCL_ERROR. Tk_Init also leaves a result or error message in
34 interp->result.
35
36 If there is a variable argv in interp, Tk_Init treats the contents of
37 this variable as a list of options for the new Tk application. The
38 options may have any of the forms documented for the wish application
39 (in fact, wish uses Tk_Init to process its command-line arguments).
40
41 Tk_SafeInit is identical to Tk_Init except that it removes all Tk com‐
42 mands that are considered unsafe. Those commands and the reasons for
43 their exclusion are:
44
45 bell Continuous ringing of the bell is a nuisance.
46
47 clipboard
48 A malicious script could replace the contents of the clipboard
49 with the string "rm -r *" and lead to surprises when the con‐
50 tents of the clipboard are pasted.
51
52 grab Grab can be used to block the user from using any other applica‐
53 tions.
54
55 menu Menus can be used to cover the entire screen and to steal input
56 from the user.
57
58 selection
59 See clipboard.
60
61 send Send can be used to cause unsafe interpreters to execute com‐
62 mands.
63
64 tk The tk command recreates the send command, which is unsafe.
65
66 tkwait Tkwait can block the containing process forever
67
68 toplevel
69 Toplevels can be used to cover the entire screen and to steal
70 input from the user.
71
72 wm If toplevels are ever allowed, wm can be used to remove decora‐
73 tions, move windows around, etc.
74
75
77 safe, application, initialization, load, main window
78
79
80
81Tk 8.0 Tk_Init(3)