home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk1.iso / answers / tcl-faq / tk / part1 next >
Encoding:
Text File  |  1994-10-12  |  57.2 KB  |  1,676 lines

  1. Newsgroups: comp.lang.tcl,comp.answers,news.answers
  2. Path: bloom-beacon.mit.edu!hookup!nntp.cs.ubc.ca!alberta!quartz.ucs.ualberta.ca!tribune.usask.ca!decwrl!ames!tulane!cpu.com!tjaccard
  3. From: tja@cpu.com (Thomas J. Accardo)
  4. Subject: FAQ: comp.lang.tcl Tk Toolkit Usage Questions And Answers (1/1)
  5. Keywords: tk, tcl, wish
  6. Followup-To: comp.lang.tcl
  7. Originator: tja@cpu.com
  8. Approved: news-answers-request@MIT.EDU
  9. Sender: tja@cpu.com
  10. Organization: Computerized Processes Unlimited Inc.
  11. Date: Wed, 12 Oct 1994 14:26:37 GMT
  12. Message-ID: <1994Oct12.142637.28981@cpu.com>
  13. Summary: A regular posting of the comp.lang.tcl Tk Toolkit usage
  14.     questions and answers.
  15. Expires: Mon, 31 Oct 1994 00:00:00 GMT
  16. Reply-To: tja@cpu.com (Thomas J. Accardo)
  17. Lines: 1656
  18. Xref: bloom-beacon.mit.edu comp.lang.tcl:18910 comp.answers:7744 news.answers:27259
  19.  
  20. Archive-name: tcl-faq/tk/part1
  21. Posting-Frequency: monthly
  22. Version: 1.1
  23. Last-modified: October 5, 1994
  24.  
  25.  
  26. This FAQ will address commonly asked questions about usage of the Tk
  27. Toolkit.  By providing answers to commonly asked questions in this
  28. document, it is hoped that new users of Tk may suffer less frustration
  29. getting started with Tk, and that readers of comp.lang.tcl may suffer
  30. less frustration reading/answering these questions repeatedly.
  31.  
  32. This FAQ is posted monthly to comp.lang.tcl, comp.answers, and
  33. news.answers and can also be obtained from the Tcl archive at
  34. ftp.aud.alcatel.com (198.64.191.10) in the /tcl/docs directory.
  35.  
  36. For additional information on Tcl as well as pointers to other
  37. documentation and code, see the FAQ maintained by Larry Virden
  38. (lvirden@cas.org):
  39.        "FAQ: comp.lang.tcl Frequently Asked Questions"
  40. which resides on ftp.aud.alcatel.com as /tcl/docs/tcl-faq.part0*.gz.
  41.  
  42. For information on usage of the Tcl programming language, see the
  43. posting by Joe Moss (joe@morton.rain.com):
  44.        "FAQ: comp.lang.tcl Tcl Language Usage Questions And Answers"
  45. which resides on ftp.aud.alcatel.com as /tcl/docs/tcl-faq-usage.gz.
  46.  
  47. Comments, suggestions, and contributions to this FAQ are welcomed
  48. at tja@cpu.com.
  49. ___________________________________________________________________________
  50.  
  51.  
  52. Index of questions:
  53.  
  54. I. Questions on building Tcl and friends on your system:
  55.     Q1A. Is there anywhere I can find help with the details of getting 
  56.         Tcl to work on my machine?
  57.     Q1B. Why does the link step says that some of the functions Tcl,
  58.         needs are missing when I am trying to build it?
  59.     Q1C. Has anyone built Tcl 6 on an RS/6000 AIX 3.1? 
  60.     Q1D. Has anyone gotten Tcl to compile under HP-UX?
  61.     Q1E. Has anyone gotten Tcl to compile under VMS?
  62.     Q1F. What does it take to get Tcl to compile under SCO Unix?
  63.     Q1G. Why do I get format and scan errors when I run tclTest
  64.         (NeXT, AIX, etc.)?
  65.     Q1H. Why do I get lots of errors under Irix 4.0.1 when I run
  66.         tclTest?
  67.     Q1I. Does anyone else have problems with Tcl on a Cray?
  68.     Q1J. Does anyone know how to get Tk to run on a SparcBook or other
  69.         laptop with a limited number of colors?
  70.     Q1K. What does it take to get Tcl/Tk to compile on 386bsd/Linux 
  71.         or other POSIX/ANSI C systems not already supported?
  72.     Q1L. Why do I get a parse error in tkInit.c when I try to compile
  73.         Tk on my Irix machine?
  74.     Q1M. What do I need to do to install Tcl 7.x/Tk 3.x on NeXTSTEP 3.1?
  75.     Q1N. Why can't I print the draft of the Tcl/Tk book?
  76.     Q1O. Why am I getting errors on my SGI Indigo workstation?
  77.     Q1P. How do I build expect on Solaris 2.3?
  78.     Q1Q. How do I add BLT to a TclX/Tk ?
  79.     Q1R. How do I port Tcl and Tk to a Sequent?
  80.     Q1S. Why do I get invalid command name when I start wish?
  81.     Q1T. How do I get around the symbol table full msg in A/UX?
  82.     Q1U. Why doesn't the Makefile generated from xmkmf work on my
  83.         SunOS system?
  84.     Q1V. How do I get Tcl to compile on my MS-DOS, MacOS, Amiga
  85.         or other micro system?
  86.     Q1W. How do I get Tcl to compile on my QNX system?
  87.  
  88. II.  Tk Questions and Answers - How can I:
  89.  
  90.     A. Question on starting Tk applications
  91.  
  92.     Q2.A.1. get my wish application to execute (I just get a wish prompt!)?
  93.     Q2.A.2. ,using a machine with less than 8 bit color, run?
  94.     Q2.A.3. set X11 resources for a wish application in an 
  95.         app-defaults file?
  96.     Q2.A.4. specify bitmap patterns on the command line instead of 
  97.         as a file name?
  98.     Q2.A.5. get a Motif user interface?
  99.     Q2.A.6. get an OpenLook user interface?
  100.     Q2.A.7. get Tk 3.3 to even start (I get security error messages)?
  101.     Q2.A.8. call Tk scripts from a C program?
  102.  
  103.     B. Questions on Tk applications and the keyboard
  104.  
  105.     Q2.B.1. change the default class bindings?
  106.     Q2.B.2. delete a binding?
  107.     Q2.B.3. change a binding while it is being executed?
  108.     Q2.B.4. bind the arrow key on my Sun keyboard?
  109.     Q2.B.5. get root's mouse bindings to work in my Tk application?
  110.     Q2.B.6. add new actions to an existing binding?
  111.  
  112.     C. Questions on Tk and X11 interactions
  113.  
  114.     Q2.C.1. get an application to also use libXt?
  115.     Q2.C.2. change the X11 cursor?
  116.     Q2.C.3. raise or lower a window?
  117.     Q2.C.4. re-map a withdrawn window id?
  118.     Q2.C.5. use Tk in a subwindow of a non-Tk X11 application?
  119.     Q2.C.6. bind <Enter> and <Leave> to a frame containing other widgets?
  120.     Q2.C.7. mix interactions between Xt and Tk/Tcl?
  121.     Q2.C.8. bind the ResizeRequest event?
  122.     Q2.C.9. avoid that 'bad geometry "+0+0": expected widthxheight'
  123.         error message?
  124.  
  125.     D. Questions on Tk listboxes
  126.  
  127.     Q2.D.1. resize a listbox?
  128.     Q2.D.2. select two items that are not adjacent in the listbox at 
  129.         one time?
  130.     Q2.D.3. select items in more than one Tk listbox at a time?
  131.     Q2.D.4. avoid fractional white space at the end of a resizable listbox?
  132.     Q2.D.5. scroll two listboxes with one scrollbar?
  133.  
  134.     E. Questions on Tk canvases
  135.  
  136.     Q2.E.1. get output from a Tk canvas?
  137.     Q2.E.2. fill a canvas which is bounded by lines as opposed to a
  138.         shape like a polygon, oval, etc.?
  139.     Q2.E.3. raise/lower canvas window objects or draw graphics onto a 
  140.         window object inside a canvas?
  141.     Q2.E.4. detect when the canvas has been resized?
  142.     Q2.E.5. scroll a canvas an a listbox at the same time with 
  143.         one scrollbar?
  144.  
  145.     F. Other questions
  146.  
  147.     Q2.F.1. get the name of my own interpreter?
  148.     Q2.F.2. get -relief to work on my text widgets?
  149.     Q2.F.3. create a scrollable window of buttons?
  150.     Q2.F.4. pack a text widget so that it can be resized interactively?
  151.     Q2.F.5. create a widget with an upper case name?
  152.     Q2.F.6. create equal sized buttons?
  153.     Q2.F.7. vertically stack radio buttons aligning regardless of font?
  154.     Q2.F.8. initialize an entry widget with some text?
  155.  
  156. End of FAQ Index
  157.  
  158. ----------------------------------------------------------------------
  159.  
  160. ------------------------------
  161.  
  162. From: -I- Questions on building Tcl and friends on your system
  163. Subject: -Q1A- Is there anywhere I can find help with the details of 
  164.         getting Tcl to work on my machine?
  165.  
  166. A1A. Glad you asked!  Look in the Tcl distribution for the file called
  167. "porting.notes".  This will contain a collection of notes that various people
  168. have provided about porting Tcl to various machines and operating systems.
  169. There are also a file called "README" which should be read FIRST - before
  170. doing anything else with the code (this should always be one's first
  171. step with any package).  Finally, there is a "changes" file which details
  172. what has changed since the last release - be sure to read this to see
  173. what might need to change in your programs.
  174.  
  175. ------------------------------
  176.  
  177. From: -I- Questions on building Tcl and friends on your system
  178. Subject: -Q1B- Why does the link step says that some of the functions Tcl,
  179.         needs are missing when I am trying to build it?
  180.  
  181. A1B. Did you run the "config" program first, by doing a "csh ./config" or
  182. equivalent?  Without doing this, things such as strtoul or strerror
  183. are sometimes mentioned as missing.
  184.  
  185. Tcl includes equivalents for at least the following functions and include files
  186. which may not be found on some systems:
  187.  
  188. dirent.h       limits.h          stdlib.h         string.h
  189.  
  190. opendir.c      strerror.c     strstr.c         strtol.c        strtoul.c
  191.  
  192. strtod.c
  193.  
  194. ------------------------------
  195.  
  196. From: -I- Questions on building Tcl and friends on your system
  197. Subject: -Q1C- Has anyone built Tcl 6 on an RS/6000 AIX 3.1? 
  198.  
  199. A1C. See porting notes - especially the note about strtoul.
  200.  
  201. One user got Tcl to compile with a few minor source modifications
  202. (for example, duplicate case statements for errno and signal symbols in 
  203. tclUnixStr.c). 
  204.  
  205. A few other problems arose in the tests.  One is caused by AIX printf
  206. not formatting %#x and %#o correctly when the value to be printed is
  207. zero:  they print "0x0" and "00" instead of "0" and "0" respectively.
  208. This was reported as not a problem in earlier releases.  No fixes have
  209. been posted.
  210.  
  211. Finally, a problem occurs in open.test.  test 13.6 hangs because "cat"
  212. on the RS6000 is unbuffered.  A workaround is to change the execution
  213. of "cat" in open.test to do a "cat -u".
  214.  
  215. Dov Grobgeld <dov@menora.weizmann.ac.il> provided info on creating Tcl
  216. and Tk shared libraries under AIX 3.1.5:
  217.  
  218. For Tcl:
  219.  
  220. cc -o tkshar.o *.o -bE:tclshar.exp -bM:SRE -berok -lX11 -lm
  221. ar r libtclshr tclshar.o
  222.  
  223. For Tk:
  224.  
  225. cc -o tkshar.o *.o -bE:tkshar.exp -bM:SRE -berok -Ltcl -lX11 -lm -ltclshr
  226. ar r libtkshr tkshar.o
  227.  
  228. where tckshar.exp and tkshar.exp had lists of the external functions.
  229.  
  230. There are also problems with fonts on AIX and the IBM.  A patch is needed
  231. from IBM to fix the X server so that fonts are working
  232.  
  233. ------------------------------
  234.  
  235. From: -I- Questions on building Tcl and friends on your system
  236. Subject: -Q1D- Has anyone gotten Tcl to compile under HP-UX?
  237.  
  238. A1D. See the porting notes.  Also, be aware that there have been
  239. some reports of Configure assuming that you should use the compatibility
  240. version of opendir() and that you have no dirent.h .  This causes 
  241. glob-ing to fail, as well as TclX's readdir, etc.
  242.  
  243. Changing tcl7.3 to remove the opendir compatibility file
  244. and removing the -DNO_DIRENT, -DUSE_DIRENT2 fixed it all up.
  245.  
  246. ------------------------------
  247.  
  248. From: -I- Questions on building Tcl and friends on your system
  249. Subject: -Q1E- Has anyone gotten Tcl to compile under VMS?
  250.  
  251. A1E. Information from jkimball@src.honeywell.com (John Kimball) on
  252. May 4, 1993 was that he had gotten Tcl 6.7 and Tk 3.2 ported to VMS
  253. 5.5.  See the catalog for the file information.
  254.  
  255. ------------------------------
  256.  
  257. From: -I- Questions on building Tcl and friends on your system
  258. Subject: -Q1F- What does it take to get Tcl to compile under SCO Unix?
  259.  
  260. A1F. Add a "#undef select" to tkEvent.c, and remove the reference to 
  261. TK_EXCEPTION around line 460 of main.c.
  262.  
  263. Tk uses its own scheme for allocating the border colors for its 3D
  264. widgets, which causes problems when running TK on a system with
  265. "PseudoColor" display class, and a 16-cell colormap.
  266.  
  267. If you can't go to eight bitplanes, you can instead start the server
  268. with a "-static" (Xsco) or "-analog" (Xsight) option, making the
  269. display class become "StaticColor".  This makes the entire colormap
  270. read-only, and it will return the color that most closely maps to the
  271. desired color as possible.
  272.  
  273. This information is from Keith Amann <Keith_Amann@stortek.com>
  274.  
  275. ------------------------------
  276.  
  277. From: -I- Questions on building Tcl and friends on your system
  278. Subject: -Q1G- Why do I get format and scan errors when I run tclTest
  279.         (NeXT, AIX, etc.)?
  280.  
  281. A1G. That's a problem (scanf/printf) many systems seem to have.  Don't
  282. worry too much about it - just don't use these 'advanced' features.  If
  283. you're hacking C, you'll have the same problems.
  284.  
  285. For instanct, printf("%Ng, double_value) and strtod("+",&terminal) produce
  286. incorrect results.
  287.  
  288. ------------------------------
  289.  
  290. From: -I- Questions on building Tcl and friends on your system
  291. Subject: -Q1H- Why do I get lots of errors under Irix 4.0.1 when I run
  292.         tclTest?
  293.  
  294. A1H. There's a bug in the 4.0.1 optimizer that's fixed in 4.0.2.
  295. Compile tclVar.c using -O0 (no optimization).
  296.  
  297. ------------------------------
  298.  
  299. From: -I- Questions on building Tcl and friends on your system
  300. Subject: -Q1I- Does anyone else have problems with Tcl on a Cray?
  301.  
  302. A1I. See the porting notes for a set of changes mentioned.  Also,
  303. Booker C. Bense <benseb@grumpy.sdsc.edu> reports that version 3.0.1.6
  304. has some real problems with char pointers, causing Tcl to crash.  Using
  305. version 3.0.2.1, things are much better, except for a minor formatting
  306. problem and serious problems with scan.
  307.  
  308. ------------------------------
  309.  
  310. From: -I- Questions on building Tcl and friends on your system
  311. Subject: -Q1J- Does anyone know how to get Tk to run on a SparcBook or other
  312.         laptop with a limited number of colors?
  313.  
  314. A1J. On a SparcBook, if you start openwin (the OpenWindows server starting
  315. command) as:
  316.  
  317. openwin -dev "/dev/fb staticvis"
  318.  
  319. you get a static visual color model that Tk copes with better than the
  320. default.  Some things are ugly, but not as ugly as monochrome.
  321.  
  322. ------------------------------
  323.  
  324. From: -I- Questions on building Tcl and friends on your system
  325. Subject: -Q1K- What does it take to get Tcl/Tk to compile on 386bsd/Linux 
  326.         or other Posix/ANSI C systems not already supported?
  327.  
  328. A1K. Patches for 386BSD were posted to comp.lang.tcl back in Nov. 1992 to
  329. alt.sources.  See one of the ftp archive sites for this group for them.
  330. Basically, there were some setting of defines and a few places where 
  331. const char * had to be used in place of char *.  
  332.  
  333. ------------------------------
  334.  
  335. From: -I- Questions on building Tcl and friends on your system
  336. Subject: -Q1L- Why do I get a parse error in tkInit.c when I try to compile
  337.         Tk on my Irix machine?
  338.  
  339. A1L. Jon Knight <J.P.Knight@loughborough.ac.uk> reports that the version of
  340. Irix that he is using doesn't define a uid_t.  One needs to define one 
  341. somewhere (or comment out the lines causing the problems) to get the compile
  342. to continue.
  343.  
  344. ------------------------------
  345.  
  346. From: -I- Questions on building Tcl and friends on your system
  347. Subject: -Q1M- What do I need to do to install Tcl 7.1/Tk 3.4 on NeXTSTEP 3.1?
  348.  
  349. A1M.  I have indicated in the past that this particular question seems
  350. to generate controversy - I have replaced previous explanations with the
  351. latest msg from someone who sounds authoritative...
  352.  
  353. From: Robert Nicholson <robert@steffi.demon.co.uk>
  354.  
  355. This is for TCL7.1 and TK3.4 
  356.  
  357. This is a variation on Thomas Funke's entry.
  358.  
  359. Installing TCL7.1 on NeXT
  360. =========================
  361.  
  362. To install tcl7.1 on NeXTSTEP 3.1 you must:
  363.  
  364. - run configure with predefined CPP:
  365.     type "sh" to run a Bourne shell.
  366.     then type
  367.     CPP='cc -E' ./configure
  368.  
  369. - edit Makefile:
  370.  
  371.   add tmpnam.o to COMPAT_OBJS:
  372.   COMPAT_OBJS =      getcwd.o waitpid.o strtod.o tmpnam.o
  373.  
  374. At this point you probably want to rename the all calls to strtod and
  375. tmpnam to something else in order to distinguish them from those that
  376. are supplied in the NeXT libraries libsys_a.a.  You can do this by 
  377. adding the following line to AC_FLAGS
  378.  
  379.     -Dstrtod=newstrtod -Dtmpnam=newtmpnam
  380.  
  381. and renaming the names of the definitions in the appropriate
  382. compat/*.c files.
  383.  
  384. To check everything is working correctly open a tclsh 
  385.  
  386. % expr {"0" == "+"} 
  387. 0
  388.  
  389. Using the wrong strtod function will cause this test to return 1 which
  390. is a serious error.  Ignore the precision errors.
  391.  
  392. Installing TK3.4 on NEXTSTEP 3.1
  393. ================================
  394.  
  395. There is a call to strtod in TK3.4 so you should link against
  396. ../tcl-7.1/compat/strtod.o and apply the -Dstrtod=newstrtod
  397. to AC_FLAGS in Tk also.
  398.  
  399. Note:Tk's raise test will fail when running the tvtwm window manager.
  400. Changing to either twm or even better fvwm ensures that this test will
  401. succeed. 
  402.  
  403. ------------------------------
  404.  
  405. From: -I- Questions on building Tcl and friends on your system
  406. Subject: -Q1N- Why can't I print the draft of the Tcl/Tk book?
  407.  
  408. A1N.  From ouster@cs.Berkeley.EDU (John Ousterhout):
  409.  
  410. Here's my form letter that seems to explain most of the problems people
  411. have had printing parts of the book:
  412.  
  413. Some old versions of the Transcript spooler software cannot properly
  414. handle encapsulated Postscript files within another Postscript file
  415. when they do page reversal.  They tend to garble the page structure of
  416. the file, causing an error at the point of the first EPS file.  Part
  417. II of the Tcl book has lots of EPS files embedded in it, one for
  418. each screen dump.  If your printer cannot print this file I suggest
  419. checking to see if page reversal is enabled for your printer.  If
  420. so, try asking your local system wizard to disable it for you;  this
  421. should allow the file to print.  Or, find some other way to dump the
  422. Postscript file directly to the printer without going through the
  423. spooling software (e.g. perhaps you can simply cat it to the printer's
  424. serial port).
  425.  
  426. Others have suggested:
  427.  
  428.  The embedded pictures have CR as the line separator instead of LF and
  429.  this may be causing the problem. Try translating them to LFs ...
  430.  
  431.    tr '\015' '\012' <book.p2.ps >fixedbook.p2.ps
  432.  
  433. and:
  434.  
  435.  This is not the original poster's problem but in countries using A4
  436.  paper and on a particular printer, the Dataproducts LZR1260E, the frame
  437.  size causes the printing to be stretched vertically. This happens with
  438.  other Framemaker generated documents by the way. A PS interpreter bug
  439.  no doubt. The fix is to edit the dimensions for A4 paper. This shell
  440.  script does both fixes.
  441.  
  442. #!/bin/sh
  443. cat $1 | tr '\015' '\012' | sed '/FMDOCUMENT$/s/612 792/595 842/'
  444.  
  445. ------------------------------
  446.  
  447. From: -I- Questions on building Tcl and friends on your system
  448. Subject: -Q1O- Why am I getting errors on my SGI Indigo workstation?
  449.  
  450. A1O. From Gordon Lack <gml4410@ggr.co.uk> we are told that
  451. the SGI c compiler has some bugs with variable arguments.
  452.  
  453. tclVar.c must be compiled with -O0 at IRIX C 4.0.1 because of a
  454. compiler bug with varargs.
  455.  
  456.    Done by placing specific rule into Makefile.
  457.  
  458. > # GGR SG needs -O0 for varargs at 4.0.1
  459. >
  460. > CC_SWITCHES0 =  -O0 -I. -I${SRC_DIR} ${AC_FLAGS} ${MATH_FLAGS} \
  461. > ${GENERIC_FLAGS} ${PROTO_FLAGS} ${MEM_DEBUG_FLAGS} \
  462. > -DTCL_LIBRARY=\"${TCL_LIBRARY}\"
  463. >
  464. > tclVar.o: tclVar.c
  465. >         $(CC) -c $(CC_SWITCHES0) $<
  466.  
  467. Peter NEELIN <neelin@pet.mni.mcgill.ca> also noted that:
  468.  
  469. I get tclX 7.3a to compile on an SGI (irix 4.0.5) with the following
  470. changes to the Config.mk file:
  471.  
  472. 71c71
  473. < CFLAGS=-cckr -D__GNU_LIBRARY__
  474. ---
  475. > #CFLAGS=
  476. 106,107c106,107
  477. < TCL_PLUS_BUILD=TCL_PLUS
  478. < CCPLUS=g++
  479. ---
  480. > #TCL_PLUS_BUILD=TCL_PLUS
  481. > CCPLUS=CC
  482. 191,193c191
  483. < MAN_DIR_SEPARATOR=
  484. < LIBOBJS=strftime.o
  485. ---
  486. > #MAN_DIR_SEPARATOR=.
  487.  
  488. The -D__GNU_LIBRARY solves the srandom problem and I think that the -cckr gets
  489. around the prototype error with waitpid (it's crude, but it works).
  490. I've forgotten why I needed the strftime.
  491.  
  492. If you want the version of Config.mk that worked for me, send me mail.
  493.  
  494. ------------------------------
  495.  
  496. From: -I- Questions on building Tcl and friends on your system
  497. Subject: -Q1P- How do I build expect on Solaris 2.3?
  498.  
  499. A1P. From jra@hrcms.jazz.att.com (Jeff Abramson) we are told that,
  500.  
  501. > using either SunPro cc 2.0.1 or gcc 2.5.8 with
  502. > no problems.  For SunPro I do:
  503. >  
  504. >         CC=cc ./configure --prefix=directory_of_your_choice
  505. >         make CC=cc
  506. >  
  507. > For gcc I do:
  508. >  
  509. >         CC="gcc -fwritable-strings" ./configure \
  510. >        --prefix=directory_of_your_choice
  511. >        make CC="gcc -fwritable-strings"
  512.  
  513. ------------------------------
  514.  
  515. From: -I- Questions on building Tcl and friends on your system
  516. Subject: -Q1Q- How do I add BLT to a TclX/Tk ?
  517.  
  518. A1Q. From gah@grenache.mhcnet.att.com (George A. Howlett) we get
  519. the answer:
  520.  
  521. Instead of adding TclX to blt_wish, try it the other way.  Add
  522. BLT to wishx.  It's pretty simple.
  523.  
  524. In the file ./tksrc/tkXAppInit.c, add the a call to the BLT
  525. initialization routine right after line 116.
  526.  
  527.     if (TkX_Init(interp) == TCL_ERROR) {
  528.         return TCL_ERROR;
  529.     }
  530.     if (Blt_Init(interp) != TCL_OK)) {
  531.         return TCL_ERROR;
  532.     }
  533.  
  534. Link wishx with libBLT.a and that's it.
  535.  
  536. Others recommend the tkmkmf or make-a-wish packages.
  537.  
  538. ------------------------------
  539.  
  540. From: -I- Questions on building Tcl and friends on your system
  541. Subject: -Q1R- How do I port Tcl and Tk to a Sequent?
  542.  
  543. A1R.  From Andrew Swan <aswan@soda.berkeley.edu> we find:
  544.  
  545. > For both Tcl and Tk, I used gcc rather than the Sequent cc which is
  546. > not ansi.
  547. > For Tcl, there were a couple of problems with the math library.  First,
  548. > the Sequent math library doesn't include the 'fmod' function.  I got
  549. > the source for fmod from ftp.uu.net, put it in the compat subdirectory,
  550. > and added it to the Makefile.  fmod also wanted functions 'isnan' and
  551. > 'finite' but I just commented those out since I don't believe tcl
  552. > supports infinity and nan.
  553. > The other problem with the math library was that it has two copies
  554. > of the 'tanh' function in it.  This is easy to fix by using "ar"
  555. > to separate the library in to object files and then reconstruct
  556. > it, leaving one of the copies of tanh out.
  557. > With those changes, Tcl compiled cleanly and passed all the tests
  558. > except the scanning tests.  Apparently, the *scanf functions are
  559. > broken in Dynix.  The problem is with recognizing the end of octal
  560. > numbers, and I just let this problem go.  Fixing it would probably
  561. > involve finding source to the *scanf functions and including it.
  562. > To compile Tk, I had to make a new version of stddef.h including
  563. > things like wchar_t.  I just copied it in to another include directory
  564. > and put that directory first and then tweaked the copy.  Tk also had
  565. > the math library problem (tanh).  Other than those, however, everything
  566. > compiled cleanly and passed all the tests.
  567.  
  568. ------------------------------
  569.  
  570. From: -I- Questions on building Tcl and friends on your system
  571. Subject: -Q1S- Why do I get invalid command name when I start wish?
  572.  
  573. A1S. Often when folks trying to build a new version of wish get done
  574. and try to start it up, they get errors such as:
  575.  
  576. >$ /projects/xopsrc/wishx3.6a            
  577. >Error: invalid command name "tk_bindForTraversal"
  578. >invalid command name "tk_bindForTraversal"
  579. >    while executing
  580. >"tk_bindForTraversal Entry"
  581. >    (file "/projects/xopsrc/Tclsrc/v7/lib/3.6a/tk.tcl" line 98)
  582. >    invoked from within
  583. >"source $tk_library/tk.tcl"
  584. >    invoked from within
  585. >"if [file exists $tk_library/tk.tcl] {
  586. >            source $tk_library/tk.tcl
  587. >        } else {
  588. >            set msg "can't find $tk_library/tk.tcl; perhaps you "
  589. >            append  ..."
  590. >
  591.  
  592. The _real_ problem is, in all likelihood, that they do not have
  593. something either configured or installed properly.  If the command name
  594. is really valid, then auto_path isn't set right, an external variable
  595. pointing to the directories is overriding the default location, or things
  596. didn't install.
  597.  
  598. ------------------------------
  599.  
  600. From: -I- Questions on building Tcl and friends on your system
  601. Subject: -Q1T- How do I get around the symbol table full msg in AU/X 3.0?
  602.  
  603. A1S. After getting things compiled on AU/X, you have to be sure
  604. to do the links with the -A {factor} arguments which expand the default
  605. table allocations.  {factor} is the amount by which the compiler multiplies
  606. the default allocation.  Try -A 2.  Contact
  607. wkulecz@medics.jsc.nasa.gov (Walter B. Kulecz, PhD.) for more details
  608. of his port.
  609.  
  610. ------------------------------
  611.  
  612. From: -I- Questions on building Tcl and friends on your system
  613. Subject: -Q1U- Why doesn't the Makefile generated from xmkmf work on my
  614.         SunOS system?
  615.  
  616. A1U. There are numerous problems users have reported when trying to use the
  617. imake / xmkmf setup under OpenWindows.  Try asking over on comp.sys.sun.*
  618. for more assistance on resolving this problem.  Note also that the problem
  619. _might_ be someone expecting X11R6 imake rules to be present - if after
  620. fixing all the known bugs in the imake templates, etc. you still have
  621. problems, investigate that!
  622.  
  623. ------------------------------
  624.  
  625. From: -I- Questions on building Tcl and friends on your system
  626. Subject: -Q1V- How do I get Tcl to compile on my MS-DOS, MacOS, Amiga
  627.         or other micro system?
  628.  
  629. A1V. (see "tcl-faq/part01") or (see "tcl-faq/part04") for details concerning
  630. tools, finished ports, or mailing lists relating to this topic.
  631.  
  632. ------------------------------
  633.  
  634. From: -I- Questions on building Tcl and friends on your system
  635. Subject: -Q1W- How do I get Tcl to compile on my QNX system?
  636.  
  637. A1W. Steve Furr <furr@qnx.com> indicates:
  638.  
  639. For the record, to get TCL to work under QNX, I had to:
  640.  
  641.   o Make the _POSIX_SOURCE change indicated for pathname lengths
  642.   o Change a definition of VARARGS, so the Watcom ANSI C compiler
  643.     would accept varargs functions used.
  644.   o Resolve a conflict with error codes defined by QNX.
  645.  
  646.  
  647. ------------------------------
  648.  
  649. From: -II-  Tk Questions and Answers - How can I:
  650. Subject: -Q2.A.1- get my wish application to execute - I just get a
  651.         wish prompt!  Or I just get error msgs about permission
  652.         denied, not found, etc.
  653.  
  654. A2.A.1. Most systems require a full pathname to the interpreter.  
  655. So you cannot start a wish script out as 
  656.  
  657. #! wish -f
  658.  
  659. Likewise, many Unix systems have a maximum length of characters that you can
  660. put on a #! line.  If you exceed this, you do not get the behaviour you
  661. expect.  So do not try to put something like:
  662.  
  663. #! /projects/somethingbig/bin/sun4/wish -f
  664.  
  665. followed by your wish code.  Keep the lines short - under 32 characters is
  666. recommended.
  667.  
  668. Finally, on some machines, white space after the -f causes a problem.  Be
  669. sure that the -f are the last characters on the first line of the file.
  670.  
  671. Another trick that has been discussed has been putting the following line
  672. as line 1 of the shell file:
  673.  
  674. /usr/ucb/tail +2 $0 | /usr/local/bin/dpwish -notk $* ; exit
  675.  
  676. where you would replace /usr/local/bin/dpwish with whatever pathname
  677. your wish needed.
  678.  
  679. Another trick that has been suggested (and attributed to Eric Schenk) is
  680. #!/usr/local/bin/wish -f
  681. # The next line is a comment in Tcl, but not sh \
  682.         exec /usr/local/bin/wish $0 -f ${1+"$@"}
  683.  
  684. Other users report symptoms such as an empty wish window without
  685. widgets.  This still turns out to be a too long interpreter path.
  686.  
  687. ------------------------------
  688.  
  689. From: -II-  Tk Questions and Answers - How can I:
  690. Subject: -Q2.A.2- ,using a machine with less than 8 bit color, run?
  691.  
  692. A2.A.2. Tk doesn't behave very well with less than 8-bit color screens.  To
  693. try to use it, find all the places in the Tk/wish source where 
  694. DefaultDepthOfScreen is invoked to test the number of bit-planes.  Change all
  695. of these to pretend there is just 1 bit-plane, or call a procedure which
  696. monitors a Tcl variable so that it is configurable, and you should be okay.
  697.  
  698. Another alternative is to see if the server you are using has alternative
  699. visual / color models, such as static visual, etc.  One of the alternatives
  700. may allow Tk to work better.
  701.  
  702. Thanks to "Nathaniel Borenstein" <nsb@thumper.bellcore.com> for this info!
  703.  
  704. ------------------------------
  705.  
  706. From: -II-  Tk Questions and Answers - How can I:
  707. Subject: -Q2.A.3- set X11 resources for a wish application in an 
  708.         app-defaults file?
  709.  
  710. A2.A.3. Read the documentation for the option command.
  711. Then you should consider something like the following - assume the program
  712. name is xwf.
  713.  
  714. The following are two general purpose functions to put into a library:
  715.  
  716. # envVal envValName
  717. #   Looks up the envValName environment variable and returns its
  718. #   value, or {} if it does not exists
  719. proc envVal {envValName} {
  720.   global env
  721.   if [info exists env($envValName)] {return $env($envValName)} {return {}}
  722. }
  723.  
  724. # loadAppDefaults classNameList ?priority?
  725. #   Searches for the app-default files corresponding to classNames in
  726. #   the order specified by X Toolkit Intrinsics, and loads them with
  727. #   the priority specified (default: startupFile).
  728. proc loadAppDefaults {classNameList {priority startupFile}} {
  729.   set filepath "[split [envVal XUSERFILESEARCHPATH] :] \
  730.         [envVal XAPPLRESDIR] \
  731.         [split [envVal XFILESEARCHPATH] :] \
  732.         /usr/lib/X11"
  733.   foreach i $classNameList {
  734.     foreach j $filepath {
  735.       if {[file exists $j/$i]} {
  736.     option readfile $j/$i $priority; break
  737.       }
  738.     }
  739.   }
  740. }
  741.  
  742. # Now, here is what you would put into xwf:
  743.  
  744. option add Tk.BoldFont "*-lucida sans-Bold-R-Normal-*-100-*" widgetDefault
  745. loadAppDefaults {xwf XWF} userDefault
  746.  
  747. This sets a program default, then load any defaults specified in the user's
  748. default resources and finally any site or general app-defaults resource.  
  749. Of course, you would want to add some xwf command line handling to allow 
  750. the user to override things at execution time.
  751.  
  752. Chris Milam (address unknown) contributes the following modification
  753. of loadAppDefaults which follows the X11R5 method of merging
  754. app-default files from several sources.
  755.  
  756. # loadAppDefaults classNameList ?priority?
  757. #   Searches for the app-default files corresponding to classNames in
  758. #   the order specified by X Toolkit Intrinsics (R5), and loads them with
  759. #   the priority specified (default: startupFile).
  760. proc loadAppDefaults {classNameList {priority startupFile}} {
  761.   set lang [envVal LANG]
  762.   if {[string length $lang] > 0} { set lang /$lang }
  763.   set filepath "\
  764.                 /usr/lib/X11${lang}/app-defaults \
  765.                 [split [envVal XFILESEARCHPATH] :] \
  766.                 [envVal XAPPLRESDIR]${lang} \
  767.                 [split [envVal XUSERFILESEARCHPATH] :] \
  768.                 "
  769.   foreach i $classNameList {
  770.     foreach j $filepath {
  771.       if {[file exists $j/$i]} {
  772.         option readfile $j/$i $priority;
  773.       }
  774.     }
  775.   }
  776. }
  777.  
  778. ------------------------------
  779.  
  780. From: -II-  Tk Questions and Answers - How can I:
  781. Subject: -Q2.A.4- specify bitmap patterns on the command line instead of 
  782.         just as a file name?
  783.  
  784. A2.A.4. You can not, using unextended Tk, at least as of June, 1992,
  785. provide a pattern as an internal set of hex codes.  You must point to
  786. an external file.  On the other hand, there are extensions which provide
  787. the capability (BLT for one)>
  788.  
  789. ------------------------------
  790.  
  791. From: -II-  Tk Questions and Answers - How can I:
  792. Subject: -Q2.A.5- get a Motif user interface?
  793.  
  794. A2.A.5. Tk does not currently use the Xt toolkit, so a strict adherence
  795. to Motif via the libXm.a routines is not possible.  However, the authors
  796. of Tk prefer the Motif style of user interface, so you will find that Tk
  797. makes quite an attempt to implement a Motif-like interface.
  798.  
  799. ------------------------------
  800.  
  801. From: -II-  Tk Questions and Answers - How can I:
  802. Subject: -Q2.A.6- get an OpenLook user interface?
  803.  
  804. A2.A.6. Unfortunately, Tk does not currently use either XView or Xt based
  805. widgets in its user interface, so an OpenLook compliant (or even
  806. similar) interface is probably not easily achievable in the near future.
  807.  
  808. ------------------------------
  809.  
  810. From: -II-  Tk Questions and Answers - How can I:
  811. Subject: -Q2.A.7- get Tk 3.3 to even start - I get security error messages.
  812.  
  813. A2.A.7.  Alternate forms of this question often mention that Tk 3.3 send
  814. is broken, or ask how to use xauth.
  815.  
  816. Under Tk 3.3, the X11 xauth security mechanism is used.  While this
  817. provides more security, it does require the user to do a bit more
  818. setup.  The user needs to create an Xauthority file (typically
  819. $HOME/.Xauthority) and then restart the X server with the
  820. -auth argument, along with the name of the Xauthority file created.
  821. Read the X11 documentation for your system for the details on how to
  822. use xauth or comparable software to create the authority files needed.
  823. An intro to xauth is available as
  824. ftp://harbor.ecn.purdue.edu/pub/tcl/docs/Xauthority .
  825.  
  826. Also note that you can configure Tk to not depend on xauth by modifying
  827. the tk3.3/Makefile.in to comment out the following:
  828.  
  829. # To turn off the security checks that disallow incoming sends when
  830. # the X server appears to be insecure, reverse the comments on the
  831. # following lines:
  832. #SECURITY_FLAGS =
  833. SECURITY_FLAGS = -DTK_NO_SECURITY
  834.  
  835. ------------------------------
  836.  
  837. From: -II-  Tk Questions and Answers - How can I:
  838. Subject: -Q2.A.8- call Tk scripts from a C program?
  839.  
  840. A2.A.8.   Several simple examples have been posted to comp.lang.tcl
  841. recently.  Eric Bleeker <ericbl@paramount.nikhefk.nikhef.nl> was 
  842. gracious enough to package his up and place it at
  843. ftp://harbor.ecn.purdue.edu/pub/tcl/code/tkHelloWorld* .  This
  844. program assumes that you have installed the Tcl and Tk libraries , 
  845. header files, etc.
  846.  
  847. ------------------------------
  848.  
  849. From: -II-  Tk Questions and Answers - How can I:
  850. Subject: -Q2.B.1- change the default class bindings?
  851.  
  852. A2.B.1. All default class bindings for Tk widgets are initialized in
  853. $tk_library/tk.tcl.  Use this file as a guide to implement new
  854. bindings.  For instance, the following code duplicates Button 1's
  855. drag-select facility in Button 3 for all listboxes:
  856.  
  857. bind Listbox <3> {%W select from [%W nearest %y]}
  858. bind Listbox <B3-Motion> {%W select to [%W nearest %y]}
  859.  
  860. ------------------------------
  861.  
  862. From: -II-  Tk Questions and Answers - How can I:
  863. Subject: -Q2.B.2- delete a binding?
  864.  
  865. A2.B.2. Give an empty-string command to the "bind" invocation.  For
  866. example, to disable the Delete key in all entry fields:
  867.  
  868.     bind Entry <Delete> {}
  869.  
  870. ------------------------------
  871.  
  872. From: -II-  Tk Questions and Answers - How can I:
  873. Subject: -Q2.B.3- change a binding while it is being executed?
  874.  
  875. A2.B.3. As of June, 1992, this was not a safe thing to do in Tk.  It was
  876. put on the bug list by John Ousterhout to be fixed in a future version.
  877.  
  878. The solution for now is not to change the bindings, but to change
  879. something in the code they execute.  For example, keep a state variable
  880. that indicates which binding you'd like, but always have the binding
  881. call a given procedure.  Then that procedure checks the variable and
  882. executes one piece of code or another.  Or, you could just make the
  883. binding's command "eval $cmd" and then change the variable "cmd"
  884. depending on your application's state.
  885.  
  886. ------------------------------
  887.  
  888. From: -II-  Tk Questions and Answers - How can I:
  889. Subject: -Q2.B.4- bind the arrow key on my Sun keyboard?
  890.  
  891. A2.B.4. You have to call it <Left> rather than <R10>.  Under X11, keys are
  892. referred to by their keysym.  One can use either xmodmap -pk or the xev
  893. program to determine what the keysym a particular key on a keyboard is
  894. currently generating.
  895.  
  896. If the keysym that is being used is not known by Tk, you may have to edit
  897. its ks_names.h file.  There is a note in this file that indicates that
  898. one should not edit it - but this is where the keysym must be for it to
  899. be recognized.
  900.  
  901. Thanks to Wayne Christopher <faustus@CS.Berkeley.EDU> for this
  902. note.
  903.  
  904. ------------------------------
  905.  
  906. From: -II-  Tk Questions and Answers - How can I:
  907. Subject: -Q2.B.5- get root's mouse bindings to work in my Tk application?
  908.  
  909. A2.B.5. Some window managers, such as mwm, define mouse button bindings
  910. which cause Tk some problems.  Try saving off the window manager's startup
  911. file (something like /.mwmrc for instance) and then copy in a startup
  912. file from a login id that works.  Thanks to brad@NeoSoft.com (Brad Morrison)
  913. for this invaluable tip!
  914.  
  915. ------------------------------
  916.  
  917. From: -II-  Tk Questions and Answers - How can I:
  918. Subject: -Q2.B.6- add new actions to an existing binding?
  919.  
  920. A2.B.6. The question was actually:
  921. >I want to bind a text window so that any keypress in that window
  922.    >updates the window's title bar.  This is what I used:
  923.    >    
  924.    >    text .textWin ...
  925.    >    bind .textWin <Any-KeyPress> {+wm title . "Nextedit - edited"}
  926.    >
  927.    >This is supposed to let the user know that the text in the window
  928.    >has been edited.  The problem is the "+".  Where does it go?  Ive
  929.    >tried a bunch of things and it always ends up with either parse 
  930.    >errors or the wm command completely overrides the binding and does
  931.    >not allow any text entry.  I need to add the new binding to the
  932.    >current ones so that a keypress enters the text *and* updates the
  933.    >titlebar.  How?
  934.    >
  935.  
  936. gwl@cpu.com (Gerald W. Lester) replied:
  937.  
  938.    You need to move the class specific binding down to the widget specific
  939.    binding.  Try this:
  940.  
  941.        bind .textWin <Any-KeyPress> Text
  942.        bind .textWin <Any-KeyPress> {+wm title . "Nextedit - edited"}
  943.  
  944. ------------------------------
  945.  
  946. From: -II-  Tk Questions and Answers - How can I:
  947. Subject: -Q2.C.1- get an application to also use libXt?
  948.  
  949. A2.C.1. Tk2.1 and Xt have different X connections, and XtAppNextEvent will
  950. block is there is nothing coming from the X connection.  One way
  951. of fixing this is get the connection number of Tk using
  952.  
  953.    ConnectionNumber(Tk_Display(tk_window));
  954.  
  955. and using XtAddInput to register this with the Xt event handler.  The
  956. callback procedure for XtAddInput wrapper procedure that runs
  957. Tk_OneEvent(1).  There might be problems with Tk file sources which
  958. aren't registered with Xt.
  959.  
  960. Thanks to joe@astro.as.utexas.edu (Joe Wang) for this information.
  961.  
  962. ------------------------------
  963.  
  964. From: -II-  Tk Questions and Answers - How can I:
  965. Subject: -Q2.C.2- change the X11 cursor?
  966.  
  967. A2.C.2. Here is a tip from mgc@cray.com (M. G. Christenson).
  968.  
  969. Look at /usr/include/X11/cursorfont.h for a list of available cursors.
  970. You can use the names in there by removing the 'XC_'.  
  971.  
  972. Here's a little proc I use to make my entire application go 'busy'
  973. while it's doing something. Just call it with the commands you want to
  974. execute, and the watch cursor will be displayed for the time it takes
  975. the commands to complete.  Note that any new windows will have their
  976. normal cursor.
  977.  
  978. proc busy {cmds} {
  979.     global errorInfo
  980.  
  981.     set busy {.app .root}
  982.     set list [winfo children .]
  983.     while {$list != ""} {
  984.     set next {}
  985.     foreach w $list {
  986.         set class [winfo class $w]
  987.         set cursor [lindex [$w config -cursor] 4]
  988.         if {[winfo toplevel $w] == $w || $cursor != ""} {
  989.         lappend busy [list $w $cursor]
  990.         }
  991.         set next [concat $next [winfo children $w]]
  992.     }
  993.     set list $next
  994.     }
  995.  
  996.     foreach w $busy {
  997.     catch {[lindex $w 0] config -cursor watch}
  998.     }
  999.  
  1000.     update idletasks
  1001.  
  1002.     set error [catch {uplevel eval [list $cmds]} result]
  1003.     set ei $errorInfo
  1004.  
  1005.     foreach w $busy {
  1006.     catch {[lindex $w 0] config -cursor [lindex $w 1]}
  1007.     }
  1008.  
  1009.     if $error {
  1010.     error $result $ei
  1011.     } else {
  1012.     return $result
  1013.     }
  1014. }
  1015.  
  1016. ------------------------------
  1017.  
  1018. From: -II-  Tk Questions and Answers - How can I:
  1019. Subject: -Q2.C.3- raise or lower a window?
  1020.  
  1021. A2.C.3. This is on the (semi-infinite) list of things to be done in the future.
  1022. If you have the time, please go ahead and add it and submit the code and all
  1023. will be grateful.
  1024.  
  1025. ------------------------------
  1026.  
  1027. From: -II-  Tk Questions and Answers - How can I:
  1028. Subject: -Q2.C.4- re-map a withdrawn window id?
  1029.  
  1030. A2.C.4. Use wm deiconify <windowid>.
  1031.  
  1032. ------------------------------
  1033.  
  1034. From: -II-  Tk Questions and Answers - How can I:
  1035. Subject: -Q2.C.5- use Tk in a subwindow of a non-Tk X11 application?
  1036.  
  1037. A2.C.5. From faustus@CS.Berkeley.EDU (Wayne A. Christopher):
  1038.  
  1039. [C]reate the Tk toplevel window but don't map it (wm withdraw).  Then
  1040. re-parent the window to be a subwindow of your other one and then map
  1041. it.  I have done this when the Tk application is a separate process,
  1042. but if it's the same process I think you will get into trouble with the
  1043. event loop, since each toolkit wants control.
  1044.  
  1045. ------------------------------
  1046.  
  1047. From: -II-  Tk Questions and Answers - How can I:
  1048. Subject: -Q2.C.6- bind <Enter> and <Leave> to a frame containing 
  1049.     other widgets?
  1050.  
  1051. A2.C.6. From John Ousterhout, ouster@cs.Berkeley.EDU):
  1052.  
  1053. Each <Enter> or <Leave> event has a "detail" field, which you can access
  1054. from bindings with "%d".  If the detail is "NotifyInferior" it means the
  1055. pointer has moved into or out of a child window (so it's really still in
  1056. the area of the window receiving the event).  You should be able to check
  1057. the detail in your scripts and ignore events with a detail of NotifyInferior.
  1058. Check the Xlib documentation for Enter/Leave events for complete
  1059. information on the detail field.
  1060.  
  1061. ------------------------------
  1062.  
  1063. From: -II-  Tk Questions and Answers - How can I:
  1064. Subject: -Q2.C.7- mix interactions between Xt and Tk/Tcl?
  1065.  
  1066. A2.C.7.
  1067.  
  1068. [From YIP Chi Lap [Beta] <h9118101@hkuxa.hku.hk> ]
  1069.     I have come up with a CPU hogging polling loop that
  1070. works (till now) for my application which not much
  1071. direct interaction between a Tk window and an Xt window is made.
  1072. (e.g., it won't draw something on a Tk window by a Xt-dispatched routine)
  1073.  
  1074.   XEvent xevent;
  1075.   for (;;)
  1076.   {
  1077.     if (XtAppPending(appcontext))
  1078.     {
  1079.       XtAppNextEvent(appcontext,&xevent);
  1080.       XtDispatchEvent(&xevent);
  1081.     }
  1082.     Tk_DoOneEvent(TK_DONT_WAIT);
  1083.   }
  1084.  
  1085. [ From David C Mudie <mudie@radon.eecs.berkeley.edu> ]
  1086.     We use the main event loop below.  The basic idea
  1087. is to watch for events arriving from either the Xt server
  1088. connection or the Tk server connection and then call
  1089. the library dispatchers.
  1090.  
  1091.     The code fragment below will need to be cleaned up for
  1092. your usage; there are some missing include statements
  1093. and global declarations buried elsewhere in the file.
  1094.  
  1095. /* Allow Tcl/Tk and Xt to work at the same time. */
  1096. void tkGo(void)
  1097. {
  1098.   extern Widget topLevel;
  1099.   int width = ulimit(4, -1);
  1100.   fd_set readfds;
  1101.   struct timeval timeout;
  1102.   int nfds;
  1103.   int tkfd = ConnectionNumber(Tk_Display(mainWindow));
  1104.   int xtfd = ConnectionNumber(XtDisplay(topLevel));
  1105.  
  1106.   Tcl_VarEval(interp, "update", NULL);
  1107.   while (1) {
  1108.  
  1109.     /* Select on X server connections to wait for event. */
  1110.     /* Timeout every half second to allow processing of non-X events */
  1111.  
  1112.     FD_ZERO(&readfds);
  1113.     FD_SET(tkfd, &readfds);
  1114.     FD_SET(xtfd, &readfds);
  1115.     timeout.tv_sec = 0;
  1116.     timeout.tv_usec = 500000;
  1117.  
  1118.     nfds = select(width, &readfds, NULL, NULL, &timeout);
  1119.     if (nfds < 0 && errno != EINTR) {
  1120.       perror("select");
  1121.     } else if (nfds == 0) {
  1122.       /* printf("timeout\n"); */
  1123.     }
  1124.  
  1125.     while (XtPending()) {
  1126.       XtProcessEvent(XtIMAll);
  1127.     }
  1128.  
  1129.     while (Tk_DoOneEvent(1)) {
  1130.       /* do nothing */
  1131.     }
  1132.   
  1133.     if (mainWindow == NULL) {
  1134. //      Tcl_DeleteInterp(interp);
  1135. //      Tcl_DStringFree(&command);
  1136.       Tcl_Eval(interp, "exit");
  1137.       return;
  1138.     }
  1139.   }
  1140. }
  1141.  
  1142. [ From Davide Frisoni <frisoni@faw.uni-ulm.de> ]
  1143.     One may use Xt properties to communicate between different
  1144. applications.
  1145.  
  1146. ------------------------------
  1147.  
  1148. From: -II-  Tk Questions and Answers - How can I:
  1149. Subject: -Q2.C.8- bind the ResizeRequest event?
  1150.  
  1151. A2.C.8.  huffi@dutncp8.tn.tudelft.nl (Martijn Figee Huffi Marcel Huefken)
  1152. says:
  1153.  
  1154. : I'm having trouble with...
  1155. :    bind .frame <ResizeRequest> {puts stdout "resise\n"}
  1156. : that is I can resize .frame and NEVER see "resize" at stdout.
  1157.  
  1158. Try 
  1159.         bind .frame <Configure> {puts...}
  1160.  
  1161. It'll work.
  1162.  
  1163. ------------------------------
  1164.  
  1165. From: -II-  Tk Questions and Answers - How can I:
  1166. Subject: -Q2.C.9- avoid that 'bad geometry "+0+0": expected widthxheight'
  1167.         error message?
  1168.  
  1169. A2.C.9.  This usually means that you have an X11 resource set that looks
  1170. like:
  1171.     *geometry: +0+0
  1172. or
  1173.     Tk*geometry: +0+0
  1174.  
  1175. Tk doesn't like this, so either remove it or fully specify the resource
  1176. in the form:
  1177.     widthxheight{+-}xoffset{+-}yoffset
  1178. such as
  1179.     Tk*geometry: 200x200+0+0
  1180.  
  1181. ------------------------------
  1182.  
  1183. From: -II-  Tk Questions and Answers - How can I:
  1184. Subject: -Q2.D.1- resize a listbox?
  1185.  
  1186. A2.D.1. Use wm min/maxsize - in a uniform manner.  Here is a resizable listbox:
  1187.  
  1188.         #!/usr/local/bin/wish -f
  1189.         wm minsize . 20 20
  1190.         wm maxsize . 1152 900
  1191.         pack append . [listbox .l -borderwidth 2 -relief raised] {expand fill}
  1192.  
  1193. Doing the same with the text widget brings its resizing under control too.
  1194.  
  1195. Thanks to "John C Ellson" <ellson@ontap.att.com).
  1196.  
  1197. ------------------------------
  1198.  
  1199. From: -II-  Tk Questions and Answers - How can I:
  1200. Subject: -Q2.D.2- select two items that are not adjacent in the listbox at 
  1201.         one time?
  1202.  
  1203. A2.D.2.  See Marc R. Ewing's Listbox.patch for a way to modify Tk to allow
  1204. selection of non-contiguous entries.
  1205.  
  1206. ------------------------------
  1207.  
  1208. From: -II-  Tk Questions and Answers - How can I:
  1209. Subject: -Q2.D.3- select items in more than one Tk listbox at a time?
  1210.  
  1211. A2.D.3. The default for Tk's listbox widget exports its selection as the
  1212. X selection.  There can only be one of these at a time.
  1213.  
  1214. To turn off this behavior in Tk, use the -exportselection false when
  1215. you create the listbox.  Or, use the
  1216.  
  1217. option add *Listbox.exportselection false
  1218.  
  1219. command in the beginning of your script.
  1220.  
  1221. Thanks to David Herron <david@davids.mmdf.com> for this tip.
  1222.  
  1223. ------------------------------
  1224.  
  1225. From: -II-  Tk Questions and Answers - How can I:
  1226. Subject: -Q2.D.4- avoid fractional white space at the end of a resizable
  1227.         listbox?
  1228.  
  1229. A2.D.4. First, let's state the problem more clearly. I want to make a
  1230. resizable listbox and I don't want to constrain it by setting a
  1231. minimum size. So I pack it with fill expand, I use it to set the grid
  1232. (so that resizing the window always gives me whole lines) and I set an
  1233. initial geometry of 1x1 to override the default. However what I get
  1234. is... (run the code below for a demo and try to resize)
  1235.  
  1236. listbox .l -geom 1x1 -setgrid 1 -yscrollcommand ".s set" -relief sunken -bd 2
  1237. scrollbar .s -command ".l yview"
  1238. pack .s -side right -fill y
  1239. pack .l -side top -fill both -expand 1
  1240. .l insert end one two three four five six seven eight nine ten "THE END"
  1241.  
  1242. ...a situation where the partially filled listbox has a blank
  1243. half-line at the bottom even if there are more items in the list. This
  1244. is very confusing because it fools the user into thinking that there
  1245. is nothing else beyond what's visible. Why does it happen?
  1246.  
  1247. Now for the answer.
  1248.     Look at the window as it is created, before the resizing. See that
  1249. poor, tiny little scrollbar squeezed in that microscopic window? It,
  1250. too, requests a minimum size, and it so happens that the starting
  1251. geometry for the listbox (i.e. the situation referred to as "1x1")
  1252. receives some free fractional space at the bottom. And you never get
  1253. rid of it, since the resizing is constrained to be in whole
  1254. characters.
  1255.  
  1256. The thing to do is to define the initial layout in such a way that the
  1257. widget that has -setgrid actually displays an integer number of lines
  1258. and columns. In the above example, setting -geom 1x2 does the trick.
  1259.  
  1260. Thanks to Frank Stajano <fms@cam-orl.co.uk> for this tip.
  1261.  
  1262. ------------------------------
  1263.  
  1264. From: -II-  Tk Questions and Answers - How can I:
  1265. Subject: -Q2.D.5- scroll two listboxes with one scrollbar?
  1266.  
  1267. A2.D.5. Scrollbars have a '-command' option which is used to tell
  1268. scrollable widgets (e.g. listbox, text, entry) how to position
  1269. themselves when the scrollbar is moved.  This command typically
  1270. looks like:
  1271.     scrollbar .scroll -command {.scrollable_widget yview}
  1272. or
  1273.     scrollbar .scroll -command {.scrollable_widget xview}
  1274.  
  1275. Before the command is executed, however, it will have a space and
  1276. a number appended to it.  The number is a logical position index
  1277. which indicates how the scrollable widget should position itself.
  1278. Thus, to have a single scrollbar control two (or more) widgets,
  1279. simply use a procedure as the scroll command, and have that
  1280. procedure scroll as many widgets as you would like.  The procedure
  1281. should take a single argument (i.e. the logical position index).
  1282. For example:
  1283.  
  1284.     proc ScrollCommand {index} {
  1285.         .lb1 yview $index
  1286.         .lb2 yview $index
  1287.         .lb3 yview $index
  1288.     }
  1289.  
  1290.     scrollbar .scroll -command ScrollCommand
  1291.  
  1292.     listbox .lb1 -geometry 4x5 -yscrollcommand {.scroll set}
  1293.     listbox .lb2 -geometry 4x5 -yscrollcommand {.scroll set}
  1294.     listbox .lb3 -geometry 4x5 -yscrollcommand {.scroll set}
  1295.     pack .scroll .lb1 .lb2 .lb3 -side left -fill y
  1296.  
  1297.     .lb1 insert 0 a b c d e f g h i j
  1298.     .lb2 insert 0 0 1 2 3 4 5 6 7 8 9
  1299.     .lb3 insert 0 A B C D E F G H I J
  1300.  
  1301.  
  1302. ------------------------------
  1303.  
  1304. From: -II-  Tk Questions and Answers - How can I:
  1305. Subject: -Q2.E.1- get output from a Tk canvas?
  1306.  
  1307. A2.E.1. The latest Tk has a save suboption on canvas which allows one
  1308. to create a file describing the canvas.  The default output is Encapsulated
  1309. Postscript, but there is an xpm3 suboption as well.
  1310.  
  1311. ------------------------------
  1312.  
  1313. From: -II-  Tk Questions and Answers - How can I:
  1314. Subject: -Q2.E.2- fill a canvas which is bounded by lines as opposed to a
  1315.         shape like a polygon, oval, etc.?
  1316.  
  1317. A2.E.2. No, you have to at least use a polygon if you want to fill an area
  1318. bounded by some lines.
  1319.  
  1320. ------------------------------
  1321.  
  1322. From: -II-  Tk Questions and Answers - How can I:
  1323. Subject: -Q2.E.3- raise/lower canvas window objects or draw graphics onto a 
  1324.         window object inside a canvas?
  1325.  
  1326. A2.E.3. You can't yet. 
  1327.  
  1328. "Jesper Blommaskog" <d9jesper@dtek.chalmers.se>.
  1329.  
  1330. ------------------------------
  1331.  
  1332. From: -II-  Tk Questions and Answers - How can I:
  1333. Subject: -Q2.E.4- detect when the canvas has been resized?
  1334.  
  1335. A2.E.4. From Nathaniel Pryce <np@hpl.hp.co.uk>:
  1336.  
  1337. > I have a window with a canvas containing some stuff that logically
  1338. > fills the canvas (say, a chess board or a map of the world). I want
  1339. > this toplevel window to be resizable and of course, when the win is
  1340. > resized, I want the stuff inside the canvas to be scaled
  1341. > accordingly. Now, I can manage the scaling of the stuff, but what
  1342. > I'm having trouble with is DETECTING that I should do it. How can I
  1343. > be notified that the window has been resized?
  1344.  
  1345. Nat's answer is:
  1346.  
  1347. You need to bind a command to the Configure event, like this:
  1348.  
  1349.     proc config {w h} {
  1350.        puts stdout ".canvas - width = $w, height = $h"
  1351.     }
  1352.  
  1353.     bind .canvas <Configure> "config %w %h"
  1354.  
  1355.  
  1356. .canvas - width = 224, height = 251
  1357. .canvas - width = 224, height = 151
  1358. .canvas - width = 224, height = 243
  1359. # and so forth
  1360.  
  1361. ------------------------------
  1362.  
  1363. From: -II-  Tk Questions and Answers - How can I:
  1364. Subject: -Q2.E.5- scroll a canvas an a listbox at the same time with 
  1365.         one scrollbar?
  1366.  
  1367. A2.E.5. From "David Herron" <david@twg.com>:
  1368.  
  1369. You need to write different code to handle the scrollcommand's.  Look at the
  1370. man page for `scrollbar' (and `listbox') and you see that it appends some
  1371. numbers to the scrollcommand such that your scrollbar command is executed as:
  1372.  
  1373.     .f.c yview; .f.lb yview <offset>
  1374.  
  1375. What I ended up doing is appended.  This code has an advantage in that
  1376. scrolling is constrained to "look right".
  1377.  
  1378.     listbox .l1    -relief sunken -yscrollcommand {
  1379.             scrollMultiple_y { .l1 .l2 .l3 } .vs
  1380.         }
  1381.     listbox .l2    -relief sunken -yscrollcommand {
  1382.             scrollMultiple_y { .l1 .l2 .l3 } .vs
  1383.         }
  1384.     listbox .l3    -relief sunken -yscrollcommand {
  1385.             scrollMultiple_y { .l1 .l2 .l3 } .vs
  1386.         }
  1387.     scrollbar .vs    -relief sunken -orient vertical \
  1388.             -command {setMultiple_y {.l1 .l2 .l3}}
  1389.  
  1390.     bind .l1 <1> {
  1391.         selectMultiple {.l1 .l2 .l3} [%W nearest %y]
  1392.     }
  1393.     bind .l1 <B1-Motion> {
  1394.         selectMultiple {.l1 .l2 .l3} [%W nearest %y]
  1395.     }
  1396.     bind .l1 <Shift-1> {
  1397.         selectMultiple {.l1 .l2 .l3} [%W nearest %y]
  1398.     }
  1399.     bind .l1 <Shift-B1-Motion> {
  1400.         selectMultiple {.l1 .l2 .l3} [%W nearest %y]
  1401.     }
  1402.  
  1403.     bind .l2 <1> {
  1404.         selectMultiple {.l1 .l2 .l3} [%W nearest %y]
  1405.     }
  1406.     bind .l2 <B1-Motion> {
  1407.         selectMultiple {.l1 .l2 .l3} [%W nearest %y]
  1408.     }
  1409.     bind .l2 <Shift-1> {
  1410.         selectMultiple {.l1 .l2 .l3} [%W nearest %y]
  1411.     }
  1412.     bind .l2 <Shift-B1-Motion> {
  1413.         selectMultiple {.l1 .l2 .l3} [%W nearest %y]
  1414.     }
  1415.  
  1416.     bind .l3 <1> {
  1417.         selectMultiple {.l1 .l2 .l3} [%W nearest %y]
  1418.     }
  1419.     bind .l3 <B1-Motion> {
  1420.         selectMultiple {.l1 .l2 .l3} [%W nearest %y]
  1421.     }
  1422.     bind .l3 <Shift-1> {
  1423.         selectMultiple {.l1 .l2 .l3} [%W nearest %y]
  1424.     }
  1425.     bind .l3 <Shift-B1-Motion> {
  1426.         selectMultiple {.l1 .l2 .l3} [%W nearest %y]
  1427.     }
  1428.  
  1429. proc scrollMultiple_y {lists vs total window first last} {
  1430.     if {[expr $first+$window] > $total} {
  1431.         set first [expr $total-$window]
  1432.         set last  [expr $first+$window]
  1433.     }
  1434.     setMultiple_y $lists $first
  1435.     $vs set $total $window $first $last
  1436. }
  1437. proc setMultiple_y  {lists index} {
  1438.     foreach l $lists { $l yview $index }
  1439. }
  1440. proc selectMultiple {lists index} {
  1441.     foreach l $lists { $l select from $index }
  1442. }
  1443.  
  1444. ------------------------------
  1445.  
  1446. From: -II-  Tk Questions and Answers - How can I:
  1447. Subject: -Q2.F.1- get the name of my own interpreter?
  1448.  
  1449. A2.F.1. george.howlett@att.com (George A. Howlett) points us to the winfo manual
  1450. page - winfo name . gets the name of the current application.
  1451.  
  1452. ------------------------------
  1453.  
  1454. From: -II-  Tk Questions and Answers - How can I:
  1455. Subject: -Q2.F.2- get -relief to work on my text widgets?
  1456.  
  1457. A2.F.2. From Owen Rees <rtor@ansa.co.uk>, we find out that we must:
  1458.  
  1459. "[m]ake the border width non-zero as in"
  1460.  
  1461.    text .t -width 20 -height 20 -relief sunken -borderwidth 4
  1462.  
  1463. ------------------------------
  1464.  
  1465. From: -II-  Tk Questions and Answers - How can I:
  1466. Subject: -Q2.F.3- create a scrollable window of buttons?
  1467.  
  1468. A2.F.3. There are at least two ways to do this.  First, there is a hypertext
  1469. widget that one can get from the Tcl User Contributed Code Archive -
  1470. (see "tcl-faq/part4") and (see "tcl-faq/part5") for details -
  1471.  which provides such a facility.
  1472.  
  1473. And here is some sample code from 
  1474. "Michael Moore" <mdm@stegosaur.cis.ohio-state.edu> which shows a way to 
  1475. do this using just Tk.
  1476.  
  1477. #! /bin/wish -f
  1478. #
  1479. # This demonstrates how to create a scrollable canvas with multiple
  1480. # buttons.
  1481. #
  1482. # Author : Michael Moore
  1483. # Date   : November 17, 1992
  1484. #
  1485.  
  1486. #
  1487. # This procedure obtains all the items with the tag "active"
  1488. # and prints out their ids.
  1489.  
  1490. proc multi_action {} {
  1491.     set list [.frame.canvas find withtag "active"]
  1492.     puts stdout "Active Item Ids : "
  1493.     foreach item $list {
  1494.     puts stdout $item
  1495.     }
  1496. }
  1497.  
  1498. # This simulates the toggling of a command button...
  1499. # Note that it only works on a color display as is right now
  1500. # but the principle is the same for b&w screens.
  1501. proc multi_activate {num id} {
  1502.     
  1503.     set tags [.frame.canvas gettags $id]
  1504.     if {[lsearch $tags "active"] != -1} {
  1505.     .frame.canvas dtag $id "active"
  1506.     .frame.canvas.button$num configure \
  1507.         -background "#060" \
  1508.         -activebackground "#080" 
  1509.     } else {
  1510.     .frame.canvas addtag "active" withtag $id
  1511.     .frame.canvas.button$num configure \
  1512.         -background "#600" \
  1513.         -activebackground "#800"
  1514.     }
  1515.  
  1516. proc setup {} {
  1517.      frame .frame
  1518.  
  1519.      scrollbar .frame.scroll \
  1520.          -command ".frame.canvas yview" \
  1521.          -relief raised
  1522.  
  1523.      canvas .frame.canvas \
  1524.          -yscroll ".frame.scroll set" \
  1525.          -scrollregion {0 0 0 650} \
  1526.          -relief raised \
  1527.      -confine false \
  1528.      -scrollincrement 25
  1529.  
  1530.      pack append .frame \
  1531.          .frame.scroll    {left frame center filly} \
  1532.          .frame.canvas    {left frame center fillx filly}
  1533.  
  1534.      pack append .\
  1535.          .frame   {left frame center fillx filly}
  1536.  
  1537.      button .frame.canvas.action  \
  1538.          -relief raised \
  1539.          -text "Action" \
  1540.      -command "multi_action"
  1541.      .frame.canvas create window 1 25 \
  1542.      -anchor w \
  1543.          -window .frame.canvas.action
  1544.      for {set i 2} {$i < 26} {incr i} {
  1545.      button .frame.canvas.button$i  \
  1546.         -relief raised \
  1547.         -background "#060" \
  1548.         -foreground wheat \
  1549.         -activebackground "#080" \
  1550.         -activeforeground wheat \
  1551.         -text "Button $i" 
  1552.      set id [.frame.canvas create window 1 [expr $i*25] \
  1553.         -anchor w \
  1554.         -window .frame.canvas.button$i]
  1555.      .frame.canvas.button$i configure \
  1556.         -command "multi_activate $i $id"
  1557.     }
  1558. }
  1559.  
  1560. setup
  1561.  
  1562. ------------------------------
  1563.  
  1564. From: -II-  Tk Questions and Answers - How can I:
  1565. Subject: -Q2.F.4- pack a text widget so that it can be resized interactively?
  1566.  
  1567. A2.F.4. From Spencer W. Thomas <spencer@med.umich.edu> we find that we need to:
  1568.  
  1569. wm minsize . 0 0
  1570. text .text
  1571. pack append . .text {fill expand}
  1572.  
  1573. ------------------------------
  1574.  
  1575. From: -II-  Tk Questions and Answers - How can I:
  1576. Subject: -Q2.F.5- create a widget with an upper case name?
  1577.  
  1578. A2.F.5. During a recent revision of Tk, things were changed so that names
  1579. beginning with a capital letter are reserved for class names.  Specific
  1580. instances of widgets must begin with a lower case letter.  This enables
  1581. X11 resource definitions to distinguish between a class and instance.
  1582.  
  1583. ------------------------------
  1584.  
  1585. From: -II-  Tk Questions and Answers - How can I:
  1586. Subject: -Q2.F.6- create equal sized buttons?
  1587.  
  1588. A2.F.6. Recently, Micael Salmon <etxmesa@eos.ericsson.se> posted:
  1589.  
  1590. In article <1993Jun23.065417.4302@ericsson.se>, I write:
  1591. |> I am currently working on yet another tn3270 emulator and I have run
  1592. |> into a problem with creating equal sized buttons. I have created an
  1593. |> array of buttons for PF and cursor keys and I would now like to make
  1594. |> them all the same size. Arranging them into columns was not
  1595. |> a problem but when I add bitmaps the buttons lose their horizontal
  1596. |> alignment. What I tried was to read the height and width of the buttons
  1597. |> using winfo, determine the largest and then use pads to force them to
  1598. |> be the same size, this doesn't seem to work. The technique of using
  1599. |> pre-set height and width doesn't seem applicable when using a mixture
  1600. |> of bitmaps and text as the size in pixels of a text button is font
  1601. |> dependent. All suggestions welcome.
  1602.  
  1603. Jim Wight <J.K.Wight@newcastle.ac.uk> suggested using reqheight and reqwidth
  1604. and then specifying padx and pady in the pack command for each button.
  1605. Jim says:
  1606. I think it only fair to point out that it was Tuomas J Lukka
  1607. <lukka@klaava.Helsinki.FI> who suggested the use of reqwidth and reqheight when I asked how to get over the deficiencies in my first attempt at a solution
  1608. that I posted to this group.
  1609.  
  1610. Since you're all agog I might as well post the final solution (more or less)
  1611. that I mailed to Michael.
  1612.  
  1613. frame .frame1
  1614. frame .frame2
  1615. button .frame1.a -text "pretty long button text"
  1616. button .frame1.b -text "short one"
  1617. button .frame2.c -bitmap "@/usr/include/X11/bitmaps/xlogo32"
  1618. button .frame2.d -text "tiny"
  1619.  
  1620. set long [winfo reqwidth .frame1.a]
  1621. set short [winfo reqwidth .frame1.b]
  1622. set medium [winfo reqwidth .frame2.c]
  1623. set tiny [winfo reqwidth .frame2.d]
  1624. set pady [expr [winfo reqheight .frame2.c]-[winfo reqheight .frame2.d]]
  1625.  
  1626. pack append .frame1 .frame1.a "filly pady $pady"
  1627. pack append .frame1 .frame1.b "fillx padx [expr $long-$short] filly pady $pady"pack append .frame2 .frame2.c "fillx padx [expr $long-$medium] filly"
  1628. pack append .frame2 .frame2.d "fillx padx [expr $long-$tiny] filly pady $pady"
  1629. pack append . .frame1 {left} .frame2 {left}
  1630.  
  1631. ------------------------------
  1632.  
  1633. From: -II-  Tk Questions and Answers - How can I:
  1634. Subject: -Q2.F.7- vertically stack radio buttons aligning regardless of font?
  1635.  
  1636. A2.F.7.  Till Brychcy <brychcy@informatik.tu-muenchen.de> provides
  1637. the following example:
  1638.  
  1639.     radiobutton .times -text Times -anchor w
  1640.     radiobutton .helvetica -text Helvetica -anchor w
  1641.     radiobutton .courier -text Courier -anchor w
  1642.     pack .times .helvetica .courier -side top -fill x
  1643.  
  1644. Note that you are using anchor west in the widgets themselves, and not in
  1645. the packer.  This lets the packer produce full width buttons.
  1646.  
  1647. ------------------------------
  1648.  
  1649. From: -II-  Tk Questions and Answers - How can I:
  1650. Subject: -Q2.F.8- initialize an entry widget with some text?
  1651.  
  1652. A2.F.8.  kesch@kappco.kapp-coburg.de (Peter Kesch) provides us with
  1653. one example:
  1654.  
  1655. set default "foobar"
  1656. entry .foo -width 25 -state disabled -textvariable default
  1657.  
  1658. ------------------------------
  1659.  
  1660.  
  1661. End of comp.lang.tcl Tk Toolkit Usage Questions and Answers (1/1)
  1662. *****************************************************
  1663. -- 
  1664. --------------------------------------
  1665. Thomas J. Accardo          tja@cpu.com
  1666. Computerized Processes Unlimited, Inc.
  1667. Metairie, LA
  1668.