home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / py2s152.zip / Modules / tkappinit.c < prev    next >
C/C++ Source or Header  |  1999-06-27  |  2KB  |  90 lines

  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 <tcl.h>
  16. #include <tk.h>
  17.  
  18. int
  19. Tcl_AppInit(interp)
  20.     Tcl_Interp *interp;
  21. {
  22.     Tk_Window main;
  23.  
  24.     main = Tk_MainWindow(interp);
  25.  
  26.     if (Tcl_Init (interp) == TCL_ERROR)
  27.         return TCL_ERROR;
  28.     if (Tk_Init (interp) == TCL_ERROR)
  29.         return TCL_ERROR;
  30.  
  31. #ifdef WITH_MOREBUTTONS
  32.     {
  33.         extern Tcl_CmdProc studButtonCmd;
  34.         extern Tcl_CmdProc triButtonCmd;
  35.  
  36.         Tcl_CreateCommand(interp, "studbutton", studButtonCmd,
  37.                   (ClientData) main, NULL);
  38.         Tcl_CreateCommand(interp, "tributton", triButtonCmd,
  39.                   (ClientData) main, NULL);
  40.     }
  41. #endif
  42.  
  43. #ifdef WITH_PIL /* 0.2b5 and later -- not yet released as of May 14 */
  44.     {
  45.         extern void TkImaging_Init(Tcl_Interp *);
  46.         TkImaging_Init(interp);
  47.         /* XXX TkImaging_Init() doesn't have the right return type */
  48.         /*Tcl_StaticPackage(interp, "Imaging", TkImaging_Init, NULL);*/
  49.     }
  50. #endif
  51.  
  52. #ifdef WITH_PIL_OLD /* 0.2b4 and earlier */
  53.     {
  54.         extern void TkImaging_Init(void);
  55.         /* XXX TkImaging_Init() doesn't have the right prototype */
  56.         /*Tcl_StaticPackage(interp, "Imaging", TkImaging_Init, NULL);*/
  57.     }
  58. #endif
  59.  
  60. #ifdef WITH_TIX
  61.         {
  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.         }
  66. #endif
  67.  
  68. #ifdef WITH_BLT
  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);
  82.     }
  83. #endif
  84.  
  85. #ifdef WITH_XXX
  86.  
  87. #endif
  88.     return TCL_OK;
  89. }
  90.