diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2001-12-09 23:15:56 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2001-12-09 23:15:56 (GMT) |
commit | cb85244228ed9261eceb71f31cd825bfcb617a70 (patch) | |
tree | 3a3cb03790e09949af696a7517292cc846b2012b /Modules/tkappinit.c | |
parent | edeea04bfd8342c5339cea701d9c6c08186a1cdb (diff) | |
download | cpython-cb85244228ed9261eceb71f31cd825bfcb617a70.zip cpython-cb85244228ed9261eceb71f31cd825bfcb617a70.tar.gz cpython-cb85244228ed9261eceb71f31cd825bfcb617a70.tar.bz2 |
Mods by Tony Lownds (patch 490100, slightly massaged by me) to make Tkinter
work with Mac OS X Aqua-Tk, all nicely within ifdefs.
The process is not for the faint of heart, though: you need to download
and install the (alfa) Aqua-Tk, obtain a few needed X11 headers from
somewhere else and then everything builds. To run scripts using Tkinter
you must build with --enable-framework, build Python.app in Mac/OSX
and run your Tkinter scripts with that. Then, about half the tests in
Demo/tkinter work (or at least do something).
Checking this in anyway because it shouldn't break anything, and newer
versions of Aqua-Tk will streamline the process.
Diffstat (limited to 'Modules/tkappinit.c')
-rw-r--r-- | Modules/tkappinit.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Modules/tkappinit.c b/Modules/tkappinit.c index c551fca..96c545d 100644 --- a/Modules/tkappinit.c +++ b/Modules/tkappinit.c @@ -20,13 +20,64 @@ Tcl_AppInit(Tcl_Interp *interp) { Tk_Window main_window; +#ifdef TK_AQUA +#ifndef MAX_PATH_LEN +#define MAX_PATH_LEN 1024 +#endif + char tclLibPath[MAX_PATH_LEN], tkLibPath[MAX_PATH_LEN]; + Tcl_Obj* pathPtr; + + /* pre- Tcl_Init code copied from tkMacOSXAppInit.c */ + Tk_MacOSXOpenBundleResources (interp, "com.tcltk.tcllibrary", + tclLibPath, MAX_PATH_LEN, 0); + + if (tclLibPath[0] != '\0') { + Tcl_SetVar(interp, "tcl_library", tclLibPath, TCL_GLOBAL_ONLY); + Tcl_SetVar(interp, "tclDefaultLibrary", tclLibPath, TCL_GLOBAL_ONLY); + Tcl_SetVar(interp, "tcl_pkgPath", tclLibPath, TCL_GLOBAL_ONLY); + } + + if (tclLibPath[0] != '\0') { + Tcl_SetVar(interp, "tcl_library", tclLibPath, TCL_GLOBAL_ONLY); + Tcl_SetVar(interp, "tclDefaultLibrary", tclLibPath, TCL_GLOBAL_ONLY); + Tcl_SetVar(interp, "tcl_pkgPath", tclLibPath, TCL_GLOBAL_ONLY); + } +#endif if (Tcl_Init (interp) == TCL_ERROR) return TCL_ERROR; + +#ifdef TK_AQUA + /* pre- Tk_Init code copied from tkMacOSXAppInit.c */ + Tk_MacOSXOpenBundleResources (interp, "com.tcltk.tklibrary", + tkLibPath, MAX_PATH_LEN, 1); + + if (tclLibPath[0] != '\0') { + pathPtr = Tcl_NewStringObj(tclLibPath, -1); + } else { + Tcl_Obj *pathPtr = TclGetLibraryPath(); + } + + if (tkLibPath[0] != '\0') { + Tcl_Obj *objPtr; + + Tcl_SetVar(interp, "tk_library", tkLibPath, TCL_GLOBAL_ONLY); + objPtr = Tcl_NewStringObj(tkLibPath, -1); + Tcl_ListObjAppendElement(NULL, pathPtr, objPtr); + } + + TclSetLibraryPath(pathPtr); +#endif + if (Tk_Init (interp) == TCL_ERROR) return TCL_ERROR; main_window = Tk_MainWindow(interp); +#ifdef TK_AQUA + TkMacOSXInitAppleEvents(interp); + TkMacOSXInitMenus(interp); +#endif + #ifdef WITH_MOREBUTTONS { extern Tcl_CmdProc studButtonCmd; |