Open Design and Integration Environment

Hex Artifact Content
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2018 Conference, Houston/TX, US, Oct 15-19
Send your abstracts to tclconference@googlegroups.com or submit via the online form
by Aug 20.

Artifact 91ad13b755f9dcb5ffe09279524a2398ef524b34:

Wiki page [Anatomy of a Toadkit project] by hypnotoad 2014-04-29 12:43:59.
0000: 44 20 32 30 31 34 2d 30 34 2d 32 39 54 31 32 3a  D 2014-04-29T12:
0010: 34 33 3a 35 39 2e 39 36 33 0a 4c 20 41 6e 61 74  43:59.963.L Anat
0020: 6f 6d 79 5c 73 6f 66 5c 73 61 5c 73 54 6f 61 64  omy\sof\sa\sToad
0030: 6b 69 74 5c 73 70 72 6f 6a 65 63 74 0a 50 20 34  kit\sproject.P 4
0040: 39 31 36 65 66 63 36 61 37 64 63 33 64 33 38 36  916efc6a7dc3d386
0050: 31 35 39 38 34 31 34 36 64 33 32 62 34 63 63 39  15984146d32b4cc9
0060: 37 31 30 37 62 38 39 0a 55 20 68 79 70 6e 6f 74  7107b89.U hypnot
0070: 6f 61 64 0a 57 20 32 31 32 36 0a 54 6f 61 64 6b  oad.W 2126.Toadk
0080: 69 74 73 20 61 72 65 20 65 73 73 65 6e 74 69 61  its are essentia
0090: 6c 6c 79 20 61 20 73 70 65 63 69 61 6c 6c 79 20  lly a specially 
00a0: 66 6f 72 6d 61 74 74 65 64 20 7a 69 70 20 66 69  formatted zip fi
00b0: 6c 65 2e 20 54 68 65 20 6e 69 63 65 20 74 68 69  le. The nice thi
00c0: 6e 67 20 61 62 6f 75 74 20 74 68 65 20 7a 69 70  ng about the zip
00d0: 20 66 69 6c 65 20 66 6f 72 6d 61 74 20 69 73 20   file format is 
00e0: 74 68 61 74 20 74 68 65 20 74 61 62 6c 65 20 6f  that the table o
00f0: 66 20 63 6f 6e 74 65 6e 74 73 20 69 73 20 6c 6f  f contents is lo
0100: 63 61 74 65 64 20 61 74 20 74 68 65 20 62 61 63  cated at the bac
0110: 6b 20 6f 66 20 74 68 65 20 66 69 6c 65 2e 20 57  k of the file. W
0120: 68 61 74 20 77 65 20 64 6f 20 66 6f 72 20 74 6f  hat we do for to
0130: 61 64 6b 69 74 73 20 69 73 20 74 6f 20 75 73 65  adkits is to use
0140: 20 61 20 70 61 72 6c 6f 72 20 74 72 69 63 6b 20   a parlor trick 
0150: 74 6f 20 74 61 63 6b 20 61 20 7a 69 70 66 69 6c  to tack a zipfil
0160: 65 20 74 6f 20 74 68 65 20 65 6e 64 20 6f 66 20  e to the end of 
0170: 61 6e 20 61 70 70 6c 69 63 61 74 69 6f 6e 20 62  an application b
0180: 69 6e 61 72 79 2e 20 42 75 74 20 77 65 20 64 6f  inary. But we do
0190: 20 69 74 20 69 6e 20 61 20 77 61 79 20 74 68 61   it in a way tha
01a0: 74 20 74 68 65 20 65 78 65 63 75 74 61 62 6c 65  t the executable
01b0: 20 70 6f 72 74 69 6f 6e 20 69 73 6e 27 74 20 6c   portion isn't l
01c0: 69 73 74 65 64 20 69 6e 20 74 68 65 20 74 61 62  isted in the tab
01d0: 6c 65 20 6f 66 20 63 6f 6e 74 65 6e 74 73 2e 20  le of contents. 
01e0: 54 68 69 73 20 74 68 65 20 6f 70 65 72 61 74 69  This the operati
01f0: 6e 67 20 73 79 73 74 65 6d 20 74 72 65 61 74 73  ng system treats
0200: 20 74 68 65 20 66 69 6c 65 20 61 73 20 61 6e 20   the file as an 
0210: 65 78 65 63 75 74 61 62 6c 65 2e 20 41 6e 64 20  executable. And 
0220: 74 68 65 20 7a 69 70 20 66 69 6c 65 20 66 6f 72  the zip file for
0230: 6d 61 74 20 74 72 65 61 74 73 20 69 74 20 61 73  mat treats it as
0240: 20 61 20 66 75 6c 6c 79 20 66 75 6e 63 74 69 6f   a fully functio
0250: 6e 69 6e 67 20 7a 69 70 20 66 69 6c 65 2e 20 0d  ning zip file. .
0260: 0a 3c 70 3e 0d 0a 54 6f 20 62 65 20 61 62 6c 65  .<p>..To be able
0270: 20 74 6f 20 6c 6f 61 64 20 74 68 65 20 7a 69 70   to load the zip
0280: 20 66 69 6c 65 20 77 65 20 68 61 76 65 20 74 6f   file we have to
0290: 20 69 6e 63 6c 75 64 65 20 61 20 6c 69 74 74 6c   include a littl
02a0: 65 20 65 78 74 72 61 20 63 6f 64 65 20 69 6e 74  e extra code int
02b0: 6f 20 54 63 6c 2f 54 6b 2e 20 54 68 69 73 20 63  o Tcl/Tk. This c
02c0: 6f 64 65 20 61 6c 6c 6f 77 73 20 54 63 6c 20 74  ode allows Tcl t
02d0: 6f 20 6d 6f 75 6e 74 20 74 68 65 20 65 78 65 63  o mount the exec
02e0: 75 74 61 62 6c 65 20 61 73 20 61 20 7a 69 70 20  utable as a zip 
02f0: 76 69 72 74 75 61 6c 20 66 69 6c 65 20 73 79 73  virtual file sys
0300: 74 65 6d 2e 20 57 65 20 61 6c 73 6f 20 69 6e 63  tem. We also inc
0310: 6c 75 64 65 20 61 20 6c 69 74 74 6c 65 20 62 6f  lude a little bo
0320: 6f 74 6c 6f 61 64 65 72 20 74 68 61 74 20 74 65  otloader that te
0330: 6c 6c 73 20 74 68 65 20 73 79 73 74 65 6d 20 74  lls the system t
0340: 6f 20 6b 69 63 6b 20 6f 66 20 61 20 66 69 6c 65  o kick of a file
0350: 20 63 61 6c 6c 65 64 20 22 6d 61 69 6e 2e 74 63   called "main.tc
0360: 6c 22 20 61 74 20 74 68 65 20 72 6f 6f 74 20 6f  l" at the root o
0370: 66 20 74 68 61 74 20 66 69 6c 65 20 73 79 73 74  f that file syst
0380: 65 6d 2e 0d 0a 3c 70 3e 0d 0a 54 6f 61 64 6b 69  em...<p>..Toadki
0390: 74 20 70 72 6f 6a 65 63 74 73 20 61 72 65 20 61  t projects are a
03a0: 20 64 69 72 65 63 74 6f 72 79 2c 20 61 6e 64 20   directory, and 
03b0: 68 65 72 65 20 61 72 65 20 74 68 65 20 6d 61 6a  here are the maj
03c0: 6f 72 20 70 6c 61 79 65 72 73 3a 0d 0a 3c 74 61  or players:..<ta
03d0: 62 6c 65 20 62 6f 72 64 65 72 3d 31 3e 0d 0a 3c  ble border=1>..<
03e0: 74 72 3e 3c 74 64 3e 4d 61 6b 65 66 69 6c 65 3c  tr><td>Makefile<
03f0: 2f 74 64 3e 3c 74 64 3e 41 20 73 63 72 69 70 74  /td><td>A script
0400: 20 63 6f 6d 70 61 74 69 62 6c 65 20 77 69 74 68   compatible with
0410: 20 74 68 65 20 3c 62 3e 6d 61 6b 65 3c 2f 62 3e   the <b>make</b>
0420: 20 73 79 73 74 65 6d 2e 20 49 74 27 73 20 77 68   system. It's wh
0430: 61 74 20 61 6c 6c 6f 77 73 20 75 73 20 74 6f 20  at allows us to 
0440: 63 61 6c 6c 20 3c 69 3e 6d 61 6b 65 3c 2f 69 3e  call <i>make</i>
0450: 20 66 72 6f 6d 20 74 68 65 20 63 6f 6d 6d 61 6e   from the comman
0460: 64 20 6c 69 6e 65 20 61 6e 64 20 6d 61 67 69 63  d line and magic
0470: 61 6c 6c 79 20 63 72 65 61 74 65 20 74 68 69 6e  ally create thin
0480: 67 73 2e 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c  gs.</td></tr>..<
0490: 74 72 3e 3c 74 64 3e 73 72 63 2f 3c 2f 74 64 3e  tr><td>src/</td>
04a0: 3c 74 64 3e 54 68 65 20 64 69 72 65 63 74 6f 72  <td>The director
04b0: 79 20 74 6f 20 62 65 20 70 6f 70 75 6c 61 74 65  y to be populate
04c0: 64 20 77 69 74 68 20 79 6f 75 72 20 63 75 73 74  d with your cust
04d0: 6f 6d 20 63 6f 64 65 2e 3c 2f 74 64 3e 3c 2f 74  om code.</td></t
04e0: 72 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 73 72 63 2f  r>..<tr><td>src/
04f0: 6d 61 69 6e 2e 74 63 6c 3c 2f 74 64 3e 3c 74 64  main.tcl</td><td
0500: 3e 54 68 69 73 20 66 69 6c 65 20 69 73 20 63 61  >This file is ca
0510: 6c 6c 65 64 20 62 79 20 74 68 65 20 74 6f 61 64  lled by the toad
0520: 6b 69 74 20 61 66 74 65 72 20 54 63 6c 2f 54 6b  kit after Tcl/Tk
0530: 20 69 6e 69 74 69 61 6c 69 7a 65 73 20 61 6e 64   initializes and
0540: 20 6d 6f 75 6e 74 73 20 74 68 65 20 76 66 73 2e   mounts the vfs.
0550: 20 41 6e 79 20 64 69 72 65 63 74 6f 72 79 20 73   Any directory s
0560: 74 72 75 63 74 75 72 65 20 69 73 20 70 72 65 73  tructure is pres
0570: 65 72 76 65 64 20 69 6e 20 74 68 65 20 66 69 6e  erved in the fin
0580: 61 6c 20 6b 69 74 2c 20 61 6e 64 20 61 63 63 65  al kit, and acce
0590: 73 73 69 62 6c 65 20 66 72 6f 6d 20 74 68 65 20  ssible from the 
05a0: 2f 7a 76 66 73 20 6d 6f 75 6e 74 70 6f 69 6e 74  /zvfs mountpoint
05b0: 2e 20 54 68 69 73 20 66 69 6c 65 20 63 61 6e 20  . This file can 
05c0: 61 6e 64 20 73 68 6f 75 6c 64 20 62 65 20 6d 6f  and should be mo
05d0: 64 69 66 69 65 64 20 74 6f 20 73 75 69 74 20 79  dified to suit y
05e0: 6f 75 72 20 61 70 70 6c 69 63 61 74 69 6f 6e 2e  our application.
05f0: 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 2f 74 61  </td></tr>..</ta
0600: 62 6c 65 3e 0d 0a 3c 70 3e 0d 0a 44 75 72 69 6e  ble>..<p>..Durin
0610: 67 20 74 68 65 20 70 72 6f 63 65 73 73 20 6f 74  g the process ot
0620: 68 65 72 20 66 69 6c 65 73 20 61 72 65 20 63 72  her files are cr
0630: 65 61 74 65 64 3a 0d 0a 3c 74 61 62 6c 65 20 62  eated:..<table b
0640: 6f 72 64 65 72 3d 31 3e 0d 0a 3c 74 72 3e 3c 74  order=1>..<tr><t
0650: 64 3e 3c 62 3e 50 52 4f 4a 45 43 54 4e 41 4d 45  d><b>PROJECTNAME
0660: 3c 2f 62 3e 2e 76 66 73 2f 3c 2f 74 64 3e 3c 74  </b>.vfs/</td><t
0670: 64 3e 41 20 64 69 72 65 63 74 6f 72 79 20 73 74  d>A directory st
0680: 72 75 63 74 75 72 65 20 74 68 61 74 20 63 6f 6d  ructure that com
0690: 62 69 6e 65 73 20 79 6f 75 72 20 2f 73 72 63 20  bines your /src 
06a0: 64 69 72 65 63 74 6f 72 79 20 77 69 74 68 20 7e  directory with ~
06b0: 2f 6f 64 69 65 2f 7a 69 70 64 69 72 20 28 77 68  /odie/zipdir (wh
06c0: 69 63 68 20 63 6f 6e 74 61 69 6e 73 20 61 6c 6c  ich contains all
06d0: 20 6f 66 20 74 68 65 20 62 69 6e 61 72 79 20 70   of the binary p
06e0: 61 63 6b 61 67 65 73 20 74 68 61 74 20 61 72 65  ackages that are
06f0: 20 62 75 6e 64 6c 65 64 20 77 69 74 68 20 74 68   bundled with th
0700: 65 20 74 6f 61 64 6b 69 74 2e 29 3c 2f 74 64 3e  e toadkit.)</td>
0710: 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 3c  </tr>..<tr><td><
0720: 62 3e 50 52 4f 4a 45 43 54 4e 41 4d 45 3c 2f 62  b>PROJECTNAME</b
0730: 3e 2e 76 66 73 2f 70 61 63 6b 61 67 65 73 2e 74  >.vfs/packages.t
0740: 63 6c 3c 2f 74 64 3e 3c 74 64 3e 41 20 6d 61 6e  cl</td><td>A man
0750: 69 66 65 73 74 20 6f 66 20 61 6c 6c 20 6f 66 20  ifest of all of 
0760: 74 68 65 20 70 61 63 6b 61 67 65 73 20 69 6e 63  the packages inc
0770: 6c 75 64 65 64 20 77 69 74 68 20 74 68 69 73 20  luded with this 
0780: 6b 69 74 2e 20 49 74 20 73 68 6f 75 6c 64 20 62  kit. It should b
0790: 65 20 73 6f 75 72 63 65 64 20 62 79 20 79 6f 75  e sourced by you
07a0: 72 20 6d 61 69 6e 2e 74 63 6c 3a 0d 0a 3c 70 72  r main.tcl:..<pr
07b0: 65 3e 0d 0a 73 6f 75 72 63 65 20 2f 7a 76 66 73  e>..source /zvfs
07c0: 2f 70 61 63 6b 61 67 65 73 2e 74 63 6c 0d 0a 3c  /packages.tcl..<
07d0: 2f 70 72 65 3e 3c 2f 74 64 3e 3c 2f 74 72 3e 0d  /pre></td></tr>.
07e0: 0a 3c 74 72 3e 3c 74 64 3e 3c 62 3e 50 52 4f 4a  .<tr><td><b>PROJ
07f0: 45 43 54 4e 41 4d 45 3c 2f 62 3e 28 2e 65 78 65  ECTNAME</b>(.exe
0800: 29 3c 2f 74 64 3e 3c 74 64 3e 54 68 65 20 66 69  )</td><td>The fi
0810: 6e 61 6c 20 65 78 65 63 75 74 61 62 6c 65 2e 3c  nal executable.<
0820: 2f 74 64 3e 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c  /td></tr>..<tr><
0830: 74 64 3e 3c 62 3e 50 52 4f 4a 45 43 54 4e 41 4d  td><b>PROJECTNAM
0840: 45 3c 2f 62 3e 2e 7a 6b 69 74 3c 2f 74 64 3e 3c  E</b>.zkit</td><
0850: 74 64 3e 41 20 76 65 72 73 69 6f 6e 20 6f 66 20  td>A version of 
0860: 79 6f 75 72 20 70 61 63 6b 61 67 65 20 77 68 69  your package whi
0870: 63 68 20 63 61 6e 20 62 65 20 6c 6f 61 64 65 64  ch can be loaded
0880: 20 62 79 20 61 20 56 46 53 20 65 6e 61 62 6c 65   by a VFS enable
0890: 64 20 54 63 6c 53 68 2f 57 69 73 68 20 75 73 69  d TclSh/Wish usi
08a0: 6e 67 20 74 68 65 20 73 6f 75 72 63 65 20 63 6f  ng the source co
08b0: 6d 6d 61 6e 64 3c 2f 74 64 3e 3c 2f 74 72 3e 0d  mmand</td></tr>.
08c0: 0a 3c 2f 74 61 62 6c 65 3e 0a 5a 20 31 63 38 33  .</table>.Z 1c83
08d0: 37 35 37 61 61 34 31 39 33 35 62 61 62 33 62 37  757aa41935bab3b7
08e0: 31 37 35 66 31 66 33 62 34 37 37 39 0a           175f1f3b4779.