blob: 392269b18c297f409de3c414b8b420b8f382e77c [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
Guido van Rossum7a206c81997-11-22 17:34:41 +000019Tcl_AppInit(interp)
Barry Warsaw845a4c61997-01-14 17:36:36 +000020 Tcl_Interp *interp;
Guido van Rossumf7132471994-06-27 08:00:16 +000021{
Barry Warsaw845a4c61997-01-14 17:36:36 +000022 Tk_Window main;
Guido van Rossumf7132471994-06-27 08:00:16 +000023
Barry Warsaw845a4c61997-01-14 17:36:36 +000024 main = Tk_MainWindow(interp);
Guido van Rossumf7132471994-06-27 08:00:16 +000025
Barry Warsaw845a4c61997-01-14 17:36:36 +000026 if (Tcl_Init (interp) == TCL_ERROR)
27 return TCL_ERROR;
28 if (Tk_Init (interp) == TCL_ERROR)
29 return TCL_ERROR;
Guido van Rossumf7132471994-06-27 08:00:16 +000030
31#ifdef WITH_MOREBUTTONS
Barry Warsaw845a4c61997-01-14 17:36:36 +000032 {
33 extern Tcl_CmdProc studButtonCmd;
34 extern Tcl_CmdProc triButtonCmd;
Guido van Rossumf7132471994-06-27 08:00:16 +000035
Barry Warsaw845a4c61997-01-14 17:36:36 +000036 Tcl_CreateCommand(interp, "studbutton", studButtonCmd,
37 (ClientData) main, NULL);
38 Tcl_CreateCommand(interp, "tributton", triButtonCmd,
39 (ClientData) main, NULL);
40 }
Guido van Rossumf7132471994-06-27 08:00:16 +000041#endif
Guido van Rossum1cbdfb91997-05-14 19:22:11 +000042
43#ifdef WITH_PIL /* 0.2b5 and later -- not yet released as of May 14 */
44 {
Guido van Rossum7a206c81997-11-22 17:34:41 +000045 extern void TkImaging_Init(Tcl_Interp *);
Guido van Rossum1cbdfb91997-05-14 19:22:11 +000046 TkImaging_Init(interp);
Guido van Rossum7a206c81997-11-22 17:34:41 +000047 /* XXX TkImaging_Init() doesn't have the right return type */
48 /*Tcl_StaticPackage(interp, "Imaging", TkImaging_Init, NULL);*/
Guido van Rossum1cbdfb91997-05-14 19:22:11 +000049 }
50#endif
51
52#ifdef WITH_PIL_OLD /* 0.2b4 and earlier */
53 {
54 extern void TkImaging_Init(void);
Guido van Rossum7a206c81997-11-22 17:34:41 +000055 /* XXX TkImaging_Init() doesn't have the right prototype */
56 /*Tcl_StaticPackage(interp, "Imaging", TkImaging_Init, NULL);*/
Guido van Rossum1cbdfb91997-05-14 19:22:11 +000057 }
58#endif
59
Guido van Rossumaec74971997-11-19 18:56:17 +000060#ifdef WITH_TIX
Guido van Rossumf259a8e1997-12-02 20:38:38 +000061 {
62 extern int Tix_Init(Tcl_Interp *interp);
63 extern int Tix_SafeInit(Tcl_Interp *interp);
64 Tcl_StaticPackage(NULL, "Tix", Tix_Init, Tix_SafeInit);
65 }
Guido van Rossumaec74971997-11-19 18:56:17 +000066#endif
67
68#ifdef WITH_BLT
Guido van Rossum7a206c81997-11-22 17:34:41 +000069 {
70 extern int Blt_Init(Tcl_Interp *);
71 extern int Blt_SafeInit(Tcl_Interp *);
72 Tcl_StaticPackage(NULL, "Blt", Blt_Init, Blt_SafeInit);
Guido van Rossumaec74971997-11-19 18:56:17 +000073 }
Guido van Rossum7a206c81997-11-22 17:34:41 +000074#endif
75
76#ifdef WITH_TOGL
77 {
78 /* XXX I've heard rumors that this doesn't work */
79 extern int Togl_Init(Tcl_Interp *);
80 /* XXX Is there no Togl_SafeInit? */
81 Tcl_StaticPackage(NULL, "Togl", Togl_Init, NULL);
82 }
Guido van Rossumaec74971997-11-19 18:56:17 +000083#endif
84
Guido van Rossumf7132471994-06-27 08:00:16 +000085#ifdef WITH_XXX
86
87#endif
Barry Warsaw845a4c61997-01-14 17:36:36 +000088 return TCL_OK;
Guido van Rossumf7132471994-06-27 08:00:16 +000089}