Untitled Document


Table of Contents


General

Introduction

GCL-TK is a windowing interface for GNU Common Lisp. It provides the functionality of the TK widget set, which in turn implements a widget set which has the look and feel of Motif.

The interface allows the user to draw graphics, get input from menus, make regions mouse sensitive, and bind lisp commands to regions. It communicates over a socket with a `gcltksrv' process, which speaks to the display via the TK library. The displaying process may run on a machine which is closer to the display, and so involves less communication. It also may remain active even though the lisp is involved in a separate user computation. The display server can, however, interrupt the lisp at will, to inquire about variables and run commands.

The user may also interface with existing TCL/TK programs, binding some buttons, or tracking some objects.

The size of the program is moderate. In its current form it adds only about 45K bytes to the lisp image, and the `gcltksrv' program uses shared libraries, and is on the order of 150Kbytes on a sparc.

This chapter describes some of the common features of the command structure of widgets, and of control functions. The actual functions for construction of windows are discussed in section Widgets, and more general functions for making them appear, lowering them, querying about them in section Control.

Getting Started

Once GCL has been properly installed you should be able to do the following simple example:

(in-package "TK")
(tkconnect)
(button '.hello :text "Hello World" :command '(print "hi"))
==>.HELLO
(pack '.hello)

We first switched to the "TK" package, so that functions like button and pack would be found. After doing the tkconnect, a window should appear on your screen, see See section tkconnect. The invocation of the function button creates a new function called .hello which is a widget function. It is then made visible in the window by using the pack function.

You may now click on the little window, and you should see the command executed in your lisp. Thus "hi" should be printed in the lisp window. This will happen whether or not you have a job running in the lisp, that is lisp will be interrupted and your command will run, and then return the control to your program.

The function button is called a widget constructor, and the function .hello is called a widget. If you have managed to accomplish the above, then GCL is probably installed correctly, and you can graduate to the next section! If you dont like reading but prefer to look at demos and code, then you should look in the demos directory, where you will find a number of examples. A monitor for the garbage collector (mkgcmonitor), a demonstration of canvas widgets (mkitems), a sample listbox with scrolling (mklistbox).

Common Features of Widgets

A widget is a lisp symbol which has a function binding. The first argument is always a keyword and is called the option. The argument pattern for the remaining arguments depends on the option. The most common option is :configure in which case the remaining arguments are alternating keyword/value pairs, with the same keywords being permitted as at the creation of the widget.

A widget is created by means of a widget constructor, of which there are currently 15, each of them appearing as the title of a section in section Widgets. They live in the "TK" package, and for the moment we will assume we have switched to this package. Thus for example button is such a widget constructor function. Of course this is lisp, and you can make your own widget constructors, but when you do so it is a good idea to follow the standard argument patterns that are outlined in this section.

(button '.hello)
==> .HELLO

creates a widget whose name is .hello. There is a parent child hierarchy among widgets which is implicit in the name used for the widget. This is much like the pathname structure on a Unix or Dos file system, except that '.' is used as the separator rather than a / or \. For this reason the widget instances are sometimes referred to as pathnames. A child of the parent widget .hello might be called .hello.joe, and a child of this last might be .hello.joe.bar. The parent of everyone is called . . Multiple top level windows are created using the toplevel command (see section toplevel).

The widget constructor functions take keyword and value pairs, which allow you to specify attributes at the time of creation:

(button '.hello :text "Hello World" :width 20)
==>.HELLO

indicating that we want the text in the button window to be Hello World and the width of the window to be 20 characters wide. Other types of windows allow specification in centimeters 2c, or in inches (2i) or in millimeters 2m or in pixels 2. But text windows usually have their dimensions specified as multiples of a character width and height. This latter concept is called a grid.

Once the window has been created, if you want to change the text you do NOT do:

(button '.hello :text "Bye World" :width 20)

This would be in error, because the window .hello already exists. You would either have to first callello :text "Helcl-tk.html#SEC123">A Entry Widget's Arguments

  • "Default Bindings"
  • Keywords
  • message
  • frame
  • label
  • radiobutton
  • toplevel
  • Control


    General

    Introduction

    GCL-TK is a windowing interface for GNU Common Lisp. It provides the functionality of the TK widget set, which in turn implements a widget set which has the look and feel of Motif.

    The interface allows the user to draw graphics, get input from menus, make regions mouse sensitive, and bind lisp commands to regions. It communicates over a socket with a `gcltksrv' process, which speaks to the display via the TK library. The displaying process may run on a machine which is closer to the display, and so involves less communication. It also may remain active even though the lisp is involved in a separate user computation. The display server can, however, interrupt the lisp at will, to inquire about variables and run commands.

    The user may also interface with existing TCL/TK programs, binding some buttons, or tracking some objects.

    The size of the program is moderate. In its current form it adds only about 45K bytes to the lisp image, and the `gcltksrv' program uses shared libraries, and is on the order of 150Kbytes on a sparc.

    This chapter describes some of the common features of the command structure of widgets, and of control functions. The actual functions for construction of windows are discussed in section Widgets, and more general functions for making them appear, lowering them, querying about them in section Control.

    Getting Started

    Once GCL has been properly installed you should be able to do the following simple example:

    (in-package "TK")
    (tkconnect)
    (button '.hello :text "Hello World" :command '(print "hi"))
    ==>.HELLO
    (pack '.hello)
    

    We first switched to the "TK" package, so that functions like button and pack would be found. After doing the tkconnect, a window should appear on your screen, see See section tkconnect. The invocation of the function button creates a new function called .hello which is a widget function. It is then made visible in the window by using the pack function.

    You may now click on the little window, and you should see the command executed in your lisp. Thus "hi" should be printed in the lisp window. This will happen whether or not you have a job running in the lisp, that is lisp will be interrupted and your command will run, and then return the control to your program.

    The function button is called a widget constructor, and the function .hello is called a widget. If you have managed to accomplish the above, then GCL is probably installed correctly, and you can graduate to the next section! If you dont like reading but prefer to look at demos and code, then you should look in the demos directory, where you will find a number of examples. A monitor for the garbage collector (mkgcmonitor), a demonstration of canvas widgets (mkitems), a sample listbox with scrolling (mklistbox).

    Common Features of Widgets

    A widget is a lisp symbol which has a function binding. The first argument is always a keyword and is called the option. The argument pattern for the remaining arguments depends on the option. The most common option is :configure in which case the remaining arguments are alternating keyword/value pairs, with the same keywords being permitted as at the creation of the widget.

    A widget is created by means of a widget constructor, of which there are currently 15, each of them appearing as the title of a section in section Widgets. They live in the "TK" package, and for the moment we will assume we have switched to this package. Thus for example button is such a widget constructor function. Of course this is lisp, and you can make your own widget constructors, but when you do so it is a good idea to follow the standard argument patterns that are outlined in this section.

    (button '.hello)
    ==> .HELLO
    

    creates a widget whose name is .hello. There is a parent child hierarchy among widgets which is implicit in the name used for the widget. This is much like the pathname structure on a Unix or Dos file system, except that '.' is used as the separator rather than a / or \. For this reason the widget instances are sometimes referred to as pathnames. A child of the parent widget .hello might be called .hello.joe, and a child of this last might be .hello.joe.bar. The parent of everyone is called . . Multiple top level windows are created using the toplevel command (see section toplevel).

    The widget constructor functions take keyword and value pairs, which allow you to specify attributes at the time of creation:

    (button '.hello :text "Hello World" :width 20)
    ==>.HELLO
    

    indicating that we want the text in the button window to be Hello World and the width of the window to be 20 characters wide. Other types of windows allow specification in centimeters 2c, or in inches (2i) or in millimeters 2m or in pixels 2. But text windows usually have their dimensions specified as multiples of a character width and height. This latter concept is called a grid.

    Once the window has been created, if you want to change the text you do NOT do:

    (button '.hello :text "Bye World" :width 20)
    

    This would be in error, because the window .hello already exists. You would either have to first callello :text "Helcl-tk.html#SEC123">A Entry Widget's Arguments

  • "Default Bindings"
  • Keywords
  • message
  • frame
  • label
  • radiobutton
  • toplevel
  • Control


    General

    Introduction

    GCL-TK is a windowing interface for GNU Common Lisp. It provides the functionality of the TK widget set, which in turn implements a widget set which has the look and feel of Motif.

    The interface allows the user to draw graphics, get input from menus, make regions mouse sensitive, and bind lisp commands to regions. It communicates over a socket with a `gcltksrv' process, which speaks to the display via the TK library. The displaying process may run on a machine which is closer to the display, and so involves less communication. It also may remain active even though the lisp is involved in a separate user computation. The display server can, however, interrupt the lisp at will, to inquire about variables and run commands.

    The user may also interface with existing TCL/TK programs, binding some buttons, or tracking some objects.

    The size of the program is moderate. In its current form it adds only about 45K bytes to the lisp image, and the `gcltksrv' program uses shared libraries, and is on the order of 150Kbytes on a sparc.

    This chapter describes some of the common features of the command structure of widgets, and of control functions. The actual functions for construction of windows are discussed in section Widgets, and more general functions for making them appear, lowering them, querying about them in section Control.

    Getting Started

    Once GCL has been properly installed you should be able to do the following simple example:

    (in-package "TK")
    (tkconnect)
    (button '.hello :text "Hello World" :command '(print "hi"))
    ==>.HELLO
    (pack '.hello)
    

    We first switched to the "TK" package, so that functions like button and pack would be found. After doing the tkconnect, a window should appear on your screen, see See section tkconnect. The invocation of the function button creates a new function called .hello which is a widget function. It is then made visible in the window by using the pack function.

    You may now click on the little window, and you should see the command executed in your lisp. Thus "hi" should be printed in the lisp window. This will happen whether or not you have a job running in the lisp, that is lisp will be interrupted and your command will run, and then return the control to your program.

    The function button is called a widget constructor, and the function .hello is called a widget. If you have managed to accomplish the above, then GCL is probably installed correctly, and you can graduate to the next section! If you dont like reading but prefer to look at demos and code, then you should look in the demos directory, where you will find a number of examples. A monitor for the garbage collector (mkgcmonitor), a demonstration of canvas widgets (mkitems), a sample listbox with scrolling (mklistbox).

    Common Features of Widgets

    A widget is a lisp symbol which has a function binding. The first argument is always a keyword and is called the option. The argument pattern for the remaining arguments depends on the option. The most common option is :configure in which case the remaining arguments are alternating keyword/value pairs, with the same keywords being permitted as at the creation of the widget.

    A widget is created by means of a widget constructor, of which there are currently 15, each of them appearing as the title of a section in section Widgets. They live in the "TK" package, and for the moment we will assume we have switched to this package. Thus for example button is such a widget constructor function. Of course this is lisp, and you can make your own widget constructors, but when you do so it is a good idea to follow the standard argument patterns that are outlined in this section.

    (button '.hello)
    ==> .HELLO
    

    creates a widget whose name is .hello. There is a parent child hierarchy among widgets which is implicit in the name used for the widget. This is much like the pathname structure on a Unix or Dos file system, except that '.' is used as the separator rather than a / or \. For this reason the widget instances are sometimes referred to as pathnames. A child of the parent widget .hello might be called .hello.joe, and a child of this last might be .hello.joe.bar. The parent of everyone is called . . Multiple top level windows are created using the toplevel command (see section toplevel).

    The widget constructor functions take keyword and value pairs, which allow you to specify attributes at the time of creation:

    (button '.hello :text "Hello World" :width 20)
    ==>.HELLO
    

    indicating that we want the text in the button window to be Hello World and the width of the window to be 20 characters wide. Other types of windows allow specification in centimeters 2c, or in inches (2i) or in millimeters 2m or in pixels 2. But text windows usually have their dimensions specified as multiples of a character width and height. This latter concept is called a grid.

    Once the window has been created, if you want to change the text you do NOT do:

    (button '.hello :text "Bye World" :width 20)
    

    This would be in error, because the window .hello already exists. You would either have to first callello :text "Helcl-tk.html#SEC123">A Entry Widget's Arguments

  • "Default Bindings"
  • Keywords
  • message
  • frame
  • label
  • radiobutton
  • toplevel
  • Control