2 '\" Copyright (c) 1994 The Regents of the University of California.
3 '\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
5 '\" See the file "license.terms" for information on usage and redistribution
6 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 .TH Tk_Main 3 4.0 Tk "Tk Library Procedures"
14 Tk_Main \- main program for Tk-based applications
19 \fBTk_Main\fR(\fIargc, argv, appInitProc\fR)
21 .AS Tcl_AppInitProc *appInitProc
23 Number of elements in \fIargv\fR.
25 Array of strings containing command-line arguments.
26 .AP Tcl_AppInitProc *appInitProc in
27 Address of an application-specific initialization procedure.
28 The value for this argument is usually \fBTcl_AppInit\fR.
33 \fBTk_Main\fR acts as the main program for most Tk-based applications.
34 Starting with Tk 4.0 it is not called \fBmain\fR anymore because it
35 is part of the Tk library and having a function \fBmain\fR
36 in a library (particularly a shared library) causes problems on many
38 Having \fBmain\fR in the Tk library would also make it hard to use
39 Tk in C++ programs, since C++ programs must have special C++
42 Normally each application contains a small \fBmain\fR function that does
43 nothing but invoke \fBTk_Main\fR.
44 \fBTk_Main\fR then does all the work of creating and running a
45 \fBwish\fR-like application.
47 When it is has finished its own initialization, but before
48 it processes commands, \fBTk_Main\fR calls the procedure given by
49 the \fIappInitProc\fR argument. This procedure provides a ``hook''
50 for the application to perform its own initialization, such as defining
51 application-specific commands. The procedure must have an interface
52 that matches the type \fBTcl_AppInitProc\fR:
54 typedef int Tcl_AppInitProc(Tcl_Interp *\fIinterp\fR);
56 \fIAppInitProc\fR is almost always a pointer to \fBTcl_AppInit\fR;
57 for more details on this procedure, see the documentation
58 for \fBTcl_AppInit\fR.
61 application-specific initialization, command-line arguments, main program