From: Robert K. <ro...@ke...> - 2001-12-06 23:10:42
|
Jim: Sorry 'bout that. A bit frazzled today. Didn't mean to call you Jeff. >> SUGGESTED CHANGE TO tkMacOSXInit.c:TkpInit() >> When a Ruby script that uses Tk starts up, it calls the following >> Tcl/Tk >> functions to get started: >> Tcl_FindExecutable >> Tcl_CreateInterp >> Tcl_Init >> Tk_Init >> What I noticed is that there are some very important looking functions >> that only get called from tkMacOSXAppInit.c:main() or >> tkMacOSXAppInit.c:Tcl_AppInit(). Specifically, they are >> tk_MacOSXSetupTkNotifier(), TkMacOSXInitAppleEvents(interp), and >> TkMacOSXInitMenus(interp). >> >> I would suggest that these three functions need to be called from >> TkpInit() which is the platform specific code called from Tk_Init. > > No, this won't work. Tk_Init gets called for each interpreter that > loads Tk > (note for instance that tkConsole.c calls this as well as the > Tcl_AppInit). > But the menu init & apple events init, and the setup notifier, are only > done > once per app. I guess we could change these functions to be > idempotent, but > since they really are for application initialization and not Tk > initialization specific things, this seems wrong to me. It was just my observation that Tk_Init seems to be the critical path function that other libraries use to make sure that Tk is ready to be used. If calling these *MacOSX* functions is necessary for a Tk program to run correctly than I think they definitely should be part of TkpInit and the functions should be modified so calling them multiple times is not a problem. Further, I would point out that on the Unix side, tkAppInit.c's implementation of Tcl_AppInit does not contain any X11 calls. It seems to rely on calls to the Tcl and Tk functions to initialize the environment for the Tk client, so it seems like something's wrong if we have Carbon calls in our Tcl_AppInit. (Though I confess with a quick look, I can't figure out where the X11 stuff all gets initialized.) > How are you building this? The easiest way to get all this right is to > use > PB, and its Carbon Application template. Short of that, set PB to issue > detailed build logs (in the Build preference pane) and then build Wish, > and > see what it does, and just copy that in your Makefile. > Jim - remember that I'm not running Wish.app *at all*. I'm using the Tk and Tcl dylib's to compile an extension to Ruby. Then, I'm running "gdb ruby" and running it appropriate arguments to run my script. By the way, here's all the small Ruby script is doing. It just puts up "hello" and "quit" buttons and sits in the main loop: <code_snippet tkHelloWorld.rb> #!/usr/bin/env ruby require "tk" TkButton.new(nil, 'text' => 'hello', 'command' => proc{print "hello\n"}).pack('fill'=>'x') TkButton.new(nil, 'text' => 'quit', 'command' => 'exit').pack('fill'=>'x') Tk.mainloop </code_snippet> To run the program, I can type "tkHelloWorld.rb" at a Terminal window or "ruby tkHelloWorld.rb" or pass the path to the script as an argument to the run command when I'm running gdb. This is a script which works on other platforms, so the goal is to get it to work on OS X with Tcl/Tk without requiring any modifications to the existing Ruby source (ideally). -Rob |