static int SetupMainInterp( Tcl_Interp *interp) { /* * Initialize the console only if we are running as an interactive * application. */ TkMacInitAppleEvents(interp); TkMacInitMenus(interp); if (strcmp(Tcl_GetVar(interp, "tcl_interactive", TCL_GLOBAL_ONLY), "1") == 0) { if (Tk_CreateConsoleWindow(interp) == TCL_ERROR) { goto error; } SetupSIOUX(); TclMacInstallExitToShellPatch(NoMoreOutput); } /* * Attach the global interpreter to tk's expected global console */ gStdoutInterp = interp; return TCL_OK; error: panic(Tcl_GetStringResult(interp)); return TCL_ERROR; }
static TkappObject * Tkapp_New(char *screenName, char *baseName, char *className, int interactive) { TkappObject *v; char *argv0; v = PyObject_New(TkappObject, &Tkapp_Type); if (v == NULL) return NULL; v->interp = Tcl_CreateInterp(); #if defined(macintosh) /* This seems to be needed */ ClearMenuBar(); TkMacInitMenus(v->interp); #endif /* Delete the 'exit' command, which can screw things up */ Tcl_DeleteCommand(v->interp, "exit"); if (screenName != NULL) Tcl_SetVar2(v->interp, "env", "DISPLAY", screenName, TCL_GLOBAL_ONLY); if (interactive) Tcl_SetVar(v->interp, "tcl_interactive", "1", TCL_GLOBAL_ONLY); else Tcl_SetVar(v->interp, "tcl_interactive", "0", TCL_GLOBAL_ONLY); /* This is used to get the application class for Tk 4.1 and up */ argv0 = (char*)ckalloc(strlen(className) + 1); if (!argv0) { PyErr_NoMemory(); Py_DECREF(v); return NULL; } strcpy(argv0, className); if (isupper((int)(argv0[0]))) argv0[0] = tolower(argv0[0]); Tcl_SetVar(v->interp, "argv0", argv0, TCL_GLOBAL_ONLY); ckfree(argv0); if (Tcl_AppInit(v->interp) != TCL_OK) return (TkappObject *)Tkinter_Error((PyObject *)v); EnableEventHook(); return v; }