From: <jca...@in...> - 2001-09-10 16:25:40
|
On Sunday 09 September 2001 01:40, Roberto Hernandez wrote: | Hi all, | | I've been trying to learn more about the initialization process of | the Tk driver. While doing that I came up with a couple of | questions, maybe some of you can help me out with these. I'm also | including some things I figured out (in case they are of any use to | anyone). | | Here are my questions: | | 1. How can I get the plplot window to start out with the DEBUG menu | enabled when using the Tk driver? If you "set debug_on 1" in procedure plserver_init in plserver.tcl,=20 it happens. But if you already knew that, then please change the=20 sources, adding "global debug_on" on the above procedure, and also at=20 pldefaults.tcl, following the same guidelines for other options,=20 submit a patch and become a plplot developper :-) We need you. Hint: "fgrep debug_on *.tcl" in the plplot tmp directory (advantages=20 of the flat model :-) | 2. When I use PLplot in Octave I can start the Tk driver and | specify a Tcl script and an empty frame to be used for the | "plxframe". The script is executed AUTOMATICALLY when "plinit" is | called. That way I can have a plot window as PART of another | window. These are the commands that are used in Octave. | =A0=A0=A0=A0=A0=A0=A0=A0 plSetOpt ("plwindow", plot_frame); | =A0=A0=A0=A0=A0=A0=A0=A0 plSetOpt ("tk_file", init_file); | How can I do the same without Octave? What you mean? In what language (or language bindings) do you intend=20 to work? plSetOpt() is a library call to setup an option (see=20 plargs.c). If you start one of the C demos, say x01c, and type ./x01c=20 -showall -h, you see two options: * -plwindow name Name of PLplot container window (tk or dp=20 driver) * -tk_file file file for plserver (tk or dp driver) These happen automatically, there is no special code in x01c.c. | 3. When is the "plw_start" procedure in | (plplotdir/lib/plplot5.0.4/tcl/plwidget.tcl) called? What I mean is | what API command calls it. I looked around but couldn't find out. That's not an API entry. Again: bash-2.04# fgrep plw_start *.tcl plclient.tcl:# plw_start_proc proc to manage the plframe widget plclient.tcl: plw_start_proc plw_end_proc \ plclient.tcl: set plw_start_proc plw_start plwidget.tcl:# plw_start plwidget.tcl:proc plw_start {w} { plwidget.tcl: catch after_plw_start bash-2.04# fgrep plw_start *.c =20 tk.c: * $plw_start_proc Does any remaining startup=20 necessary tk.c: server_cmd( pls, "$plw_start_proc $plwindow", 1 ); ( you can also build a tags file (etags *.c *.h *.tcl) open (x)emacs,=20 and find the tag you want, browsing throug the code--but I'm not a=20 sofisticated user :) So, it looks like plw_start is called at tk.c, the tk driver source=20 code. But tk.c is not an easy code to digest; it is a standard driver that=20 at driver initialization time atach to a tk interpreter, than=20 fork/exec (launch) the plserver, establish a communication link=20 between the attached tk and plserver, and then use that channel to=20 send/receive commands to plserver. I'm not shure that this completely=20 correct. It looks like there can exist two kinds of links: either tk standard=20 "send", when the program that uses the tk driver is on the same X=20 display that plserver, and a network socket implemented with "dp",=20 when the programs are running on diferent machines (but I think that=20 "dp"--a tcl extension-- is not in use anymore--not shure again). | 4. I have a suggestion for a small change in the procedure | "plw_start" (hope this is the right list). The change and reason | for it are specified at the end of this mail. | | ------------------------------------------- | | From what I've been able to tell, the most important procedures | that are executed during the "tk" driver initialization process | are: | | 1. plserver_init (plplotdir/lib/plplot5.0.4/tcl/plserver.tcl) - | Sets up the top menubar with the File and Help menus | =A0 =A0 =A0 =A0|| =A0 =A0 =A0 calls | =A0 =A0 =A0 =A0v | 2. plstdwin (plplotdir/lib/plplot5.0.4/tcl/pltools.tcl) - Runs the | pldefaluts and plconfig procedures to set up the options and sets | the minimum window size and geometry. | | =A0 =A0 =A0 =A0 =A0(don't know who calls this, probably plinit) | 3. plw_create (plplotdir/lib/plplot5.0.4/tcl/plwidget.tcl) | =A0 =A0 =A0 =A0|| =A0 =A0 =A0 calls | =A0 =A0 =A0 =A0v | 4. plxframe (plplotdir/lib/plplot5.0.4/tcl/plwidget.tcl) - Creates | a container frame (unless already specified) and puts the plot_menu | and plframe (for the actual plot) inside it. | | =A0 =A0 =A0 =A0 =A0(don't know who calls this, probably plinit) This is the important part, I think | 5. plw_start (plplotdir/lib/plplot5.0.4/tcl/plwidget.tcl) - Packs | the container frame that was either specified by the user or | created by "plxframe". Tells the client that the widget is ready. | Calls a procedure "after_plw_start" which is optional code the user | can write if he needs to execute anything after the driver | initialization is done. | | ------------------------------------------ | | When the "plinit" command is called with the "tk" driver the | procedure "plxframe" is used. This procedure creates a "container" | frame and within that frame are the "plot_menu" (if enabled) and a | "plframe". | | There is the option to specify a tcl script and an empty frame for | the plxframe to be created in. The procedure that initializes the | "tk" driver DOESN'T CHECK whether the specified container frame has | been mapped or not. It just PACKS the frame. If the frame had been | previoulsy mapped with a geometry manager other than PACK it causes | the process to lock up. Roberto problem is, if I undestood correctly (we have been talking=20 off-list): "if I write a tk interface using my prefered geometry=20 manager, the "grid", and let an empty frame on it, where I want the=20 plots to go--using plSetOpt ("plwindow", plot_frame)--then the=20 program blocks, because plserver *packs* the frame that is already=20 "grided". | So here there are two options: | | a) Make sure all the widgets that are siblings of the specified | "container" frame are managed with PACK. | | b) Modify the procedure that initializes the "tk" driver to check | whether the specified container frame has been mapped or not before | packing it. | | The procedure in charge of doing the packing is "plw_start" which | is in the "plplotdir/lib/plplot5.0.4/tcl/plwidget.tcl" file. The | change is as follows: | | [old] | # Manage widget hierarchy | =A0 =A0 pack append [winfo parent $w] $w \ | =A0 =A0 =A0 =A0{bottom expand fill} | | =A0 =A0 update | | [new] | # Manage widget hierarchy | =A0 =A0 if {! [winfo ismapped $w]} { =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0<--- | only change pack append [winfo parent $w] $w \ | =A0=A0=A0=A0=A0=A0=A0=A0 =A0 =A0 =A0 =A0{bottom expand fill} | =A0 =A0 } | | =A0 =A0 update | It does not work for me, if I try "./x01c -dev tk", I get invalid command name "=A0" while executing "=A0" (procedure "plw_start" line 6) invoked from within "plw_start .x01c" ("after" script) Haven't you done any other changes? The changes I made: bash-2.04# diff -c plwidget.tcl plwidget.tcl.new *** plwidget.tcl Mon Sep 10 16:51:49 2001 --- plwidget.tcl.new Mon Sep 10 16:51:14 2001 *************** *** 575,583 **** global client =20 # Manage widget hierarchy !=20 pack append [winfo parent $w] $w \ {bottom expand fill} =20 update =20 --- 575,586 ---- global client =20 # Manage widget hierarchy ! if (1) { ! if {! [winfo ismapped $w]} { =A0 pack append [winfo parent $w] $w \ {bottom expand fill} + }} else { pack append [winfo parent $w] $w \ + {bottom expand fill}} update Joao | Regards, | | - Roberto | | _______________________________________________ | Plplot-general mailing list | Plp...@li... | https://lists.sourceforge.net/lists/listinfo/plplot-general |