blob: c551fcab44d5c5e2b22149c1a3ceb49ad2eca6a1 [file] [log] [blame]
Guido van Rossum7a206c81997-11-22 17:34:41 +00001/* appinit.c -- Tcl and Tk application initialization.
2
3 The function Tcl_AppInit() below initializes various Tcl packages.
4 It is called for each Tcl interpreter created by _tkinter.create().
5 It needs to be compiled with -DWITH_<package> flags for each package
6 that you are statically linking with. You may have to add sections
7 for packages not yet listed below.
8
9 Note that those packages for which Tcl_StaticPackage() is called with
10 a NULL first argument are known as "static loadable" packages to
11 Tcl but not actually initialized. To use these, you have to load
12 it explicitly, e.g. tkapp.eval("load {} Blt").
13 */
Guido van Rossumf7132471994-06-27 08:00:16 +000014
15#include <tcl.h>
16#include <tk.h>
17
18int
Peter Schneider-Kampfaaad372000-07-10 09:26:41 +000019Tcl_AppInit(Tcl_Interp *interp)
Guido van Rossumf7132471994-06-27 08:00:16 +000020{
Moshe Zadka6a078ed2000-08-04 15:53:06 +000021 Tk_Window main_window;
Guido van Rossumf7132471994-06-27 08:00:16 +000022
Barry Warsaw845a4c61997-01-14 17:36:36 +000023 if (Tcl_Init (interp) == TCL_ERROR)
24 return TCL_ERROR;
25 if (Tk_Init (interp) == TCL_ERROR)
26 return TCL_ERROR;
Guido van Rossumf7132471994-06-27 08:00:16 +000027
Moshe Zadka6a078ed2000-08-04 15:53:06 +000028 main_window = Tk_MainWindow(interp);
Guido van Rossume168c651999-11-05 18:11:23 +000029
Guido van Rossumf7132471994-06-27 08:00:16 +000030#ifdef WITH_MOREBUTTONS
Barry Warsaw845a4c61997-01-14 17:36:36 +000031 {
32 extern Tcl_CmdProc studButtonCmd;
33 extern Tcl_CmdProc triButtonCmd;
Guido van Rossumf7132471994-06-27 08:00:16 +000034
Barry Warsaw845a4c61997-01-14 17:36:36 +000035 Tcl_CreateCommand(interp, "studbutton", studButtonCmd,
Moshe Zadka6a078ed2000-08-04 15:53:06 +000036 (ClientData) main_window, NULL);
Barry Warsaw845a4c61997-01-14 17:36:36 +000037 Tcl_CreateCommand(interp, "tributton", triButtonCmd,
Moshe Zadka6a078ed2000-08-04 15:53:06 +000038 (ClientData) main_window, NULL);
Barry Warsaw845a4c61997-01-14 17:36:36 +000039 }
Guido van Rossumf7132471994-06-27 08:00:16 +000040#endif
Guido van Rossum1cbdfb91997-05-14 19:22:11 +000041
42#ifdef WITH_PIL /* 0.2b5 and later -- not yet released as of May 14 */
43 {
Guido van Rossum7a206c81997-11-22 17:34:41 +000044 extern void TkImaging_Init(Tcl_Interp *);
Guido van Rossum1cbdfb91997-05-14 19:22:11 +000045 TkImaging_Init(interp);
Guido van Rossum7a206c81997-11-22 17:34:41 +000046 /* XXX TkImaging_Init() doesn't have the right return type */
47 /*Tcl_StaticPackage(interp, "Imaging", TkImaging_Init, NULL);*/
Guido van Rossum1cbdfb91997-05-14 19:22:11 +000048 }
49#endif
50
51#ifdef WITH_PIL_OLD /* 0.2b4 and earlier */
52 {
53 extern void TkImaging_Init(void);
Guido van Rossum7a206c81997-11-22 17:34:41 +000054 /* XXX TkImaging_Init() doesn't have the right prototype */
55 /*Tcl_StaticPackage(interp, "Imaging", TkImaging_Init, NULL);*/
Guido van Rossum1cbdfb91997-05-14 19:22:11 +000056 }
57#endif
58
Guido van Rossumaec74971997-11-19 18:56:17 +000059#ifdef WITH_TIX
Guido van Rossumf259a8e1997-12-02 20:38:38 +000060 {
61 extern int Tix_Init(Tcl_Interp *interp);
62 extern int Tix_SafeInit(Tcl_Interp *interp);
63 Tcl_StaticPackage(NULL, "Tix", Tix_Init, Tix_SafeInit);
64 }
Guido van Rossumaec74971997-11-19 18:56:17 +000065#endif
66
67#ifdef WITH_BLT
Guido van Rossum7a206c81997-11-22 17:34:41 +000068 {
69 extern int Blt_Init(Tcl_Interp *);
70 extern int Blt_SafeInit(Tcl_Interp *);
71 Tcl_StaticPackage(NULL, "Blt", Blt_Init, Blt_SafeInit);
Guido van Rossumaec74971997-11-19 18:56:17 +000072 }
Guido van Rossum7a206c81997-11-22 17:34:41 +000073#endif
74
75#ifdef WITH_TOGL
76 {
77 /* XXX I've heard rumors that this doesn't work */
78 extern int Togl_Init(Tcl_Interp *);
79 /* XXX Is there no Togl_SafeInit? */
80 Tcl_StaticPackage(NULL, "Togl", Togl_Init, NULL);
81 }
Guido van Rossumaec74971997-11-19 18:56:17 +000082#endif
83
Guido van Rossumf7132471994-06-27 08:00:16 +000084#ifdef WITH_XXX
85
86#endif
Barry Warsaw845a4c61997-01-14 17:36:36 +000087 return TCL_OK;
Guido van Rossumf7132471994-06-27 08:00:16 +000088}