[Pythonmac-SIG] Newbie asks : Current state of play for
Python on Mac OS X 10.1?
Tony Lownds
tony@metanet.com
Wed, 5 Dec 2001 22:35:05 -0800
That technote was really really useful!! After some
much-more-productive-than-before debugging, I have a working
Tkinter/Aqua. Well, at least the hello.py demo works. The patch and
Setup.local file are below.
-Tony
Index: _tkinter.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_tkinter.c,v
retrieving revision 1.120
diff -u -r1.120 _tkinter.c
--- _tkinter.c 2001/11/28 20:27:42 1.120
+++ _tkinter.c 2001/12/06 06:17:36
@@ -41,8 +41,13 @@
#define MAC_TCL
#endif
+#ifdef TK_FRAMEWORK
+#include <Tcl/tcl.h>
+#include <Tk/tk.h>
+#else
#include <tcl.h>
#include <tk.h>
+#endif
#define TKMAJORMINOR (TK_MAJOR_VERSION*1000 + TK_MINOR_VERSION)
@@ -454,6 +459,7 @@
ClearMenuBar();
TkMacInitMenus(v->interp);
#endif
+
/* Delete the 'exit' command, which can screw things up */
Tcl_DeleteCommand(v->interp, "exit");
@@ -1579,8 +1585,8 @@
TkttObject *v = (TkttObject *)self;
char buf[100];
- PyOS_snprintf(buf, sizeof(buf), "<tktimertoken at %p%s>", v,
- v->func == NULL ? ", handler deleted" : "");
+ sprintf(buf, "<tktimertoken at %p%s>", v,
+ v->func == NULL ? ", handler deleted" : "");
return PyString_FromString(buf);
}
@@ -2136,6 +2142,22 @@
Tktt_Type.ob_type = &PyType_Type;
PyDict_SetItemString(d, "TkttType", (PyObject *)&Tktt_Type);
+
+
+#ifdef TK_AQUA
+ /* Tk_MacOSXSetupTkNotifier must be called before Tcl's subsystems
+ * start waking up. Note that Tcl_FindExecutable will do this, this
+ * code must be above it! The original warning from
+ * tkMacOSXAppInit.c is copied below.
+ *
+ * NB - You have to swap in the Tk Notifier BEFORE you start up the
+ * Tcl interpreter for now. It probably should work to do this
+ * in the other order, but for now it doesn't seem to.
+ *
+ */
+ Tk_MacOSXSetupTkNotifier();
+#endif
+
/* This helps the dynamic loader; in Unicode aware Tcl versions
it also helps Tcl find its encodings. */
Index: tkappinit.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/tkappinit.c,v
retrieving revision 1.9
diff -u -r1.9 tkappinit.c
--- tkappinit.c 2000/08/04 15:53:06 1.9
+++ tkappinit.c 2001/12/06 06:17:36
@@ -15,17 +15,68 @@
#include <tcl.h>
#include <tk.h>
+#define MAX_PATH_LEN 1000
+
int
Tcl_AppInit(Tcl_Interp *interp)
{
Tk_Window main_window;
+#ifdef TK_AQUA
+ 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;
- if (Tk_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
{
--------------------- Setup.local ---------------------
# Edit this file for local setup changes
*shared*
_tkinter _tkinter.c tkappinit.c -DWITH_APPINIT -DTK_AQUA \
-I/Library/Frameworks/Tcl.framework/Headers/ \
-I/Library/Frameworks/Tcl.framework/Versions/Current/PrivateHeaders/ \
-I/Library/Frameworks/Tk.framework/Headers/ \
-I/Library/Frameworks/Tk.framework/Versions/Current/PrivateHeaders/ \
-I/usr/X11R6/include/ \
-framework Tcl -framework Tk
At 3:11 PM -0500 12/5/01, Steven Majewski wrote:
>On Wed, 5 Dec 2001, Tony Lownds wrote:
>
>> >Tony? Are you still with us? Status, please?
>>
>> I am completely stuck on this. Does anyone with experience debugging
>> Mac apps want to take over/help? Unix experience isn't helping me on
>> this one.
>
>FYI: One of the recent technotes:
> TN2030: GDB for MacsBug Veterans
> <http://developer.apple.com/technotes/tn/tn2030.html>
>has come in handy for me. I always knew just enough GDB to
>get by debugging unix command line programs -- debugging a
>GUI app for OSX seems to require a few more tricks.
>
>-- Steve
>
>
>
>_______________________________________________
>Pythonmac-SIG maillist - Pythonmac-SIG@python.org
>http://mail.python.org/mailman/listinfo/pythonmac-sig
--