This is a nightly snapshot of the Guile Tcl/Tk interface. This module allows you to use the Tcl programming language, and more interestingly, the Tk user interface toolkit, from Guile. Please send bug reports to bug-guile@prep.ai.mit.edu. NOTE: The following instructions assumes that you have configured your guile library with the --with-threads option. (If you are unsure about whether this is the case on your system you can check that the symbol `threads' is present in the scheme variable `*features*'.) See below for instructions on how to use `guile-tcltk' without threads. Requirements ========================================================= This package should be used together with tcl7.[56] and tk4.[12]. It does not work together with tk8.0. How to get started =================================================== 1. Install the package according to the instructions in INSTALL. 2. Run `guile-tcltk' 3. Type the following expressions at the Guile prompt: (use-modules (tcltk tcltk)) (tk-main-window) The Tk application window should now appeare on the screen. 4. Now type: (define b (button #f :text "Hello")) (pack b) The window should now change appearance and display a button. 5. Type: (proc hello () (display "Hello!\n")) (b 'configure :command 'hello) When you press the button something should be displayed in your interpreter window... Demos ================================================================ Hand ---- (use-modules (tcltk hand)) (hand) starts the demo: a hand turning anti-clockwise. Use (stop) to stop and (start) to start again. Graph ----- (use-modules (tcltk graph)) This will cause an application window to appear on the screen. Press mouse button 1 to create circles. Drag circles with mouse button 2. Press key `1' in a circle to "mark" it. Press key `2' on another circle to draw a line to it. Press `q' to quit. If you have closed the window you can use `(graph)' to create it again. Breakout -------- (use-modules (tcltk breakout)) (play-game) will start the game. Short manual ========================================================= Module name is (tcltk tcltk) - variable: the-interpreter The current interpreter object. All access to tcl/tk goes through an interpreter. Some functions use this variable implicitly. All resources, like scheme procedures visible in tcl name space, are GC protected through the interpreter object. These resources can be released by removing all references to the interpreter. - procedure: new-interpreter Create a new interpreter and store ut in `the-interpreter'. - procedure: tk-make-main-window [NAME] [GEOMETRY] Create the Tk application window. GEOMETRY is a string representing the window geometry in standard X syntax. Note that the window won't appear on the screen until there is some kind of Tk event handler running (e.g. `tk-main-loop'). - procedure: tk-main-window? Returns #t if the current interpreter has an living Tk application window. - primitive: tk-num-main-windows Return the number of Tk application windows. - primitive: tk-main-loop The Tk event loop. - primitive: tk-loop? Return #t if `tk-main-loop' is running. - procedure: tk-spawn-handler Spawns a thread running `tk-main-loop'. If another handler already is running, exit immediately. Exits when no application windows remain. - procedure: tk-main-window [NAME] [GEOMETRY] Create the Tk application window and spawn a handler. It is equivalent to a call to `tk-make-main-window' followed by a call to `tk-spawn-handler'. Tk widgets have two syntaxes: New style --------- (WIDGET-COMMAND PARENT ... [:name NAME] ...) --> WIDGET PARENT can be #f or another widget. The component name of the widget will be NAME if supplied, otherwise WIDGET-COMMAND#. The path name will be . if PARENT is #f, otherwise .. Examples: (define f (frame #f :name 'foo)) => f has path name .foo (define b (button f :text "Test")) => b has path name .foo.button#1 Old style --------- (WIDGET_COMMAND PATH-NAME ...) --> PATH-NAME PATH-NAME is the intended path name of the widget. As a side-effect, a tcl procedure named PATH-NAME is created on the Scheme and tcl sides. Using guile-tcltk without threads ==================================== The procedures `tk-spawn-handler' and `tk-main-window' are unavailable if libguile on your system is compiled without threads. You will then have to use `tk-main-loop' or `tcl-do-one-event' directly in order to handle Tk events. Since the demos use these procedures, they won't run without a threaded guile, at least not without some modification. Important Facts About Snapshots ====================================== Please keep in mind that these sources are strictly experimental; they will usually not be well-tested, and may not even compile on some systems. They may contain interfaces which will change. They will usually not be of sufficient quality for use by people not comfortable hacking the innards of Guile. Caveat! However, we're providing them anyway for several reasons. We'd like to encourage people to get involved in developing Guile. People willing to use the bleeding edge of development can get earlier access to new, experimental features. Patches submitted relative to recent snapshots will be easier for us to evaluate and install, since the patch's original sources will be closer to what we're working with. And it allows us to start testing features earlier. Nightly snapshots of the Guile Tcl/Tk interface development sources are available via anonymous FTP from ftp.red-bean.com, in /pub/guile/guile-tcltk-snap.tar.gz. Via the web, that's: ftp://ftp.red-bean.com/pub/guile/guile-tcltk-snap.tar.gz For getit, that's: ftp.red-bean.com:/pub/guile/guile-tcltk-snap.tar.gz The latest official Guile release is available via anonymous FTP from prep.ai.mit.edu, as /pub/gnu/guile-1.0.tar.gz. Via the web, that's: ftp://prep.ai.mit.edu/pub/gnu/guile-1.0.tar.gz For getit, that's: prep.ai.mit.edu:/pub/gnu/guile-1.0.tar.gz The mailing list `guile@cygnus.com' carries discussions, questions, and often answers, about Guile and associated packages. To subscribe, send mail to guile-request@cygnus.com. Of course, please send bug reports (and fixes!) to bug-guile@prep.ai.mit.edu. About This Distribution ============================================== To build this package (the Guile Tcl/Tk interface), you must have already built installed the Guile core. Building and installing this distribution gives you: guile-tcltk --- a stand-alone interpreter for Guile with the Tcl/Tk interface linked in, usually installed in /usr/local/bin. With no arguments, this is a simple interactive Scheme interpreter with access to Tcl and Tk. It can also be used as an interpreter for script files; see the Guile core NEWS file for details. libgtcltk.a --- an object library containing the Guile Tcl/Tk interface, usually installed in /usr/local/lib. You can use the interface in your own programs by linking against this library, and -lguile. tcltk/tcltk.scm --- The scheme part of the Tk interface tcltk/graph.scm --- Demo tcltk/breakout.scm --- Another demo Interesting files include: - COPYING, which describes the terms under which you may redistribute Guile, and explains that there is no warranty. Hacking It Yourself ================================================== As distributed, the Guile Tcl/Tk interface needs only an installed version of Tcl/Tk, an ANSI C compiler and a Unix system to compile. However, guile-tcltk's makefiles, configuration scripts, and a few other files are automatically generated, not written by hand. If you want to make changes to the system (which we encourage!) you will find it helpful to have the tools we use to develop Guile. They are the following: Autoconf 2.13 --- a system for automatically generating `configure' scripts from templates which list the non-portable features a program would like to use. Available in "ftp://prep.ai.mit.edu/pub/gnu". Automake 1.4 --- a system for automatically generating Makefiles that conform to the (rather Byzantine) GNU coding standards. The nice thing is that it takes care of hairy targets like 'make dist' and 'make distclean', and automatically generates Makefile dependencies. Available in "ftp://prep.ai.mit.edu/pub/gnu". libtool 1.2 --- a system for managing the zillion hairy options needed on various systems to produce shared libraries. Available in "ftp://prep.ai.mit.edu/pub/gnu". You are lost in a little maze of automatically generated files, all different. > Authors And Contributors ============================================= Many people have generously contributed to Guile. However, any errors are the responsibility of the primary Guile maintainer, Jim Blandy. Tom Lord wrote the Guile/Tcl/Tk interface, among many other things. Mikael Djurfeldt rehacked the scheme part of the interface (tcltk.scm). Keith Wright invented the new style widget syntax.