General Information


Introduction

This library of EuLisp modules is trying to provide the possibility of calling Tk functionality from youtoo interpreter. We use to refer to this library as youtoo/Tk system.

What is Tk?
Tk is nothing else than a toolkit for the X Window system. Tk provides commands for building user interfaces, so that the programmer will be able to construct Motif-like user interfaces easily and faster. Tk gives the programmer a set of functions to create and handle user interface widgets. Consequently the coder does not need to write large and criptyc C codes that have to interact with the X System. Tk was created as an extension to Tcl, which is a simple scripting language for controlling applications.

What is youtoo?
youtoo is one possible implementation of the object oriented programming language EuLisp. youtoo was built and is still being improved by The School of Mathematical Sciences in the University of Bath. EuLisp is a dialect of Lisp. It is being discussed and created since 1985. EuLisp provides new features to the former definitions and implementations of Lisp language. The most important ones are:

  1. The integration of the classical Lisp type system and the object system into a single class hierarchy.
  2. The complementary abstraction facilities provided by the class and the module mechanism.
  3. Support for concurrent execution.

youtoo provides all these features defined in EuLisp language definition.

Lots of information could be found in youtoo site

This documentation

This documentation shows some aspects of the produced binding. Some of the commands of Tcl/Tk are not implemented, because youtoo provides the necessary features.

The next description tries to explain what has been done. The EuLisp commands always have the correspondent Tcl/Tk command. The general syntax is the same that the manual pages for Tcl7.5 and tk4.1 use.

The manual pages could be found in the next URL: http://www.sco.com/Technology/tcl/Tcl.html


Getting Started

This section will explain the necessary steps in order to start producing the interface.

  1. Import the module tcl-tk in your import list. That is:
             (defmodule your-module
                (syntax (macros)
                 import (level1 tcl-tk))
    
  2. Add all the commands and functions to create and manage Tk widgets from youtoo.
    There is a list of commands in Tk commands in EuLisp section.

  3. Add the event service loop at the end of your main module.
    More details are given in the next section Event-Driven applications.

  4. Compilation. Have you install the correspondent libraries?
    1. Be sure that the path for tcl/Tk libraries is correct in your .eulrc file.
      Path for the X library also need to be specified. That is:
         (CLIBS . "-Lpath -lX11 
                   -Lpath -ltk4.1 
                   -Lpath -ltcl7.5 
                   -lm")
      
    2. Compile your module. Use:
      youtoo your-module -l level1 -l tcl-tk
      
  5. Execute your EuLisp program. Remember to set properly the environment variable DISPLAY.
    The generated program can also handle the display variable. So that:
       your-module -display your-display
    

Event - Driven

Tk library works over the X System, that implies that almost everything is event-driven. That is, the execution flow is controled by events. The application reacts to determinate events.

youtoo/Tk is not indifferent to that. The applications in youtoo/Tk will be event-driven.

This is possible thanks to a couple of features that youtoo/Tk provides:

  1. Callback mecanism. See How to manage callbacks section.
  2. Special functions to dispatch events.

    1. Tcl_DoOneEvent. Go to Tk commands section
    2. Tk_MainLoop. Go to Tk commands section

    These two functions are enough to produce event-driven applications with youtto/Tk. Tk_MainLoop loops calling Tcl_DoOneEvent with the blocking option.

    The idea is that, if your application is single threaded it is enough using Tcl_MainLoop.
    If your application needs to be doing different things apart from being dispatching Tk event, then create a new thread. The next example will show this:

    (defun loop-function ()
      (while t
        (Tcl_DoOneEvent 1)
        (thread-reschedule)))
    
    (deflocal loop-thread (make <thread> function: loop-function))
    (thread-start loop-thread)