Skip to content

Commit 7a206c8

Browse files
committed
New tkappinit supporting several popular packages.
1 parent 7d5b99d commit 7a206c8

File tree

1 file changed

+36
-15
lines changed

1 file changed

+36
-15
lines changed

Modules/tkappinit.c

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
/* appinit.c -- Tcl and Tk application initialization. */
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+
*/
214

315
#include <tcl.h>
416
#include <tk.h>
517

6-
#ifdef WITH_BLT
7-
#include "blt.h"
8-
#endif
9-
1018
int
11-
Tcl_AppInit (interp)
19+
Tcl_AppInit(interp)
1220
Tcl_Interp *interp;
1321
{
1422
Tk_Window main;
@@ -34,31 +42,44 @@ Tcl_AppInit (interp)
3442

3543
#ifdef WITH_PIL /* 0.2b5 and later -- not yet released as of May 14 */
3644
{
37-
extern void TkImaging_Init(Tcl_Interp *interp);
45+
extern void TkImaging_Init(Tcl_Interp *);
3846
TkImaging_Init(interp);
47+
/* XXX TkImaging_Init() doesn't have the right return type */
48+
/*Tcl_StaticPackage(interp, "Imaging", TkImaging_Init, NULL);*/
3949
}
4050
#endif
4151

4252
#ifdef WITH_PIL_OLD /* 0.2b4 and earlier */
4353
{
4454
extern void TkImaging_Init(void);
45-
TkImaging_Init();
55+
/* XXX TkImaging_Init() doesn't have the right prototype */
56+
/*Tcl_StaticPackage(interp, "Imaging", TkImaging_Init, NULL);*/
4657
}
4758
#endif
4859

4960
#ifdef WITH_TIX
50-
if (Tix_Init (interp) == TCL_ERROR) {
51-
fprintf(stderr, "Tix_Init error: #s\n", interp->result);
52-
return TCL_ERROR;
61+
{
62+
extern int Tix_Init(Tcl_Interp *);
63+
/* XXX Is there no Tix_SafeInit? */
64+
Tcl_StaticPackage(NULL, "Tix", Tix_Init, NULL);
5365
}
5466
#endif
5567

5668
#ifdef WITH_BLT
57-
if (Blt_Init(interp) != TCL_OK) {
58-
fprintf(stderr, "BLT_Init error: #s\n", interp->result);
59-
return TCL_ERROR;
69+
{
70+
extern int Blt_Init(Tcl_Interp *);
71+
extern int Blt_SafeInit(Tcl_Interp *);
72+
Tcl_StaticPackage(NULL, "Blt", Blt_Init, Blt_SafeInit);
73+
}
74+
#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);
6082
}
61-
Tcl_StaticPackage(interp, "Blt", Blt_Init, Blt_SafeInit);
6283
#endif
6384

6485
#ifdef WITH_XXX

0 commit comments

Comments
 (0)