• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* 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  */
14 
15 #include <string.h>
16 #include <tcl.h>
17 #include <tk.h>
18 
19 #include "tkinter.h"
20 
21 int
Tcl_AppInit(Tcl_Interp * interp)22 Tcl_AppInit(Tcl_Interp *interp)
23 {
24     const char *_tkinter_skip_tk_init;
25 
26     if (Tcl_Init (interp) == TCL_ERROR)
27         return TCL_ERROR;
28 
29 #ifdef WITH_XXX
30         /* Initialize modules that don't require Tk */
31 #endif
32 
33     _tkinter_skip_tk_init =     Tcl_GetVar(interp,
34                     "_tkinter_skip_tk_init", TCL_GLOBAL_ONLY);
35     if (_tkinter_skip_tk_init != NULL &&
36                     strcmp(_tkinter_skip_tk_init, "1") == 0) {
37         return TCL_OK;
38     }
39 
40     if (Tk_Init(interp) == TCL_ERROR) {
41         return TCL_ERROR;
42     }
43 
44     Tk_MainWindow(interp);
45 
46 #ifdef WITH_PIL /* 0.2b5 and later -- not yet released as of May 14 */
47     {
48         extern void TkImaging_Init(Tcl_Interp *);
49         TkImaging_Init(interp);
50         /* XXX TkImaging_Init() doesn't have the right return type */
51         /*Tcl_StaticPackage(interp, "Imaging", TkImaging_Init, NULL);*/
52     }
53 #endif
54 
55 #ifdef WITH_PIL_OLD /* 0.2b4 and earlier */
56     {
57         extern void TkImaging_Init(void);
58         /* XXX TkImaging_Init() doesn't have the right prototype */
59         /*Tcl_StaticPackage(interp, "Imaging", TkImaging_Init, NULL);*/
60     }
61 #endif
62 
63 #ifdef WITH_TIX
64     {
65         extern int Tix_Init(Tcl_Interp *interp);
66         extern int Tix_SafeInit(Tcl_Interp *interp);
67         Tcl_StaticPackage(NULL, "Tix", Tix_Init, Tix_SafeInit);
68     }
69 #endif
70 
71 #ifdef WITH_BLT
72     {
73         extern int Blt_Init(Tcl_Interp *);
74         extern int Blt_SafeInit(Tcl_Interp *);
75         Tcl_StaticPackage(NULL, "Blt", Blt_Init, Blt_SafeInit);
76     }
77 #endif
78 
79 #ifdef WITH_TOGL
80     {
81         /* XXX I've heard rumors that this doesn't work */
82         extern int Togl_Init(Tcl_Interp *);
83         /* XXX Is there no Togl_SafeInit? */
84         Tcl_StaticPackage(NULL, "Togl", Togl_Init, NULL);
85     }
86 #endif
87 
88 #ifdef WITH_XXX
89 
90 #endif
91     return TCL_OK;
92 }
93