1Tk_Main(3) Tk Library Procedures Tk_Main(3)
2
3
4
5______________________________________________________________________________
6
8 Tk_Main - main program for Tk-based applications
9
11 #include <tk.h>
12
13 Tk_Main(argc, argv, appInitProc)
14
16 int argc (in) Number of elements in argv.
17
18 char *argv[] (in) Array of strings containing
19 command-line arguments.
20
21 Tcl_AppInitProc *appInitProc (in) Address of an application-
22 specific initialization pro‐
23 cedure. The value for this
24 argument is usually
25 Tcl_AppInit.
26_________________________________________________________________
27
28
30 Tk_Main acts as the main program for most Tk-based applications.
31 Starting with Tk 4.0 it is not called main anymore because it is part
32 of the Tk library and having a function main in a library (particularly
33 a shared library) causes problems on many systems. Having main in the
34 Tk library would also make it hard to use Tk in C++ programs, since C++
35 programs must have special C++ main functions.
36
37 Normally each application contains a small main function that does
38 nothing but invoke Tk_Main. Tk_Main then does all the work of creating
39 and running a wish-like application.
40
41 When it is has finished its own initialization, but before it processes
42 commands, Tk_Main calls the procedure given by the appInitProc argu‐
43 ment. This procedure provides a “hook” for the application to perform
44 its own initialization, such as defining application-specific commands.
45 The procedure must have an interface that matches the type Tcl_AppInit‐
46 Proc:
47 typedef int Tcl_AppInitProc(Tcl_Interp *interp);
48 AppInitProc is almost always a pointer to Tcl_AppInit; for more details
49 on this procedure, see the documentation for Tcl_AppInit.
50
51
53 application-specific initialization, command-line arguments, main pro‐
54 gram
55
56
57
58Tk 4.0 Tk_Main(3)