---
name: "xpce"
section: "1"
platform: "linux"
package: "swi-prolog-x"
version: "8.0.2+dfsg-3+deb10u1"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/xpce"
---

# xpce(1)

Prolog with graphical user interface (GUI)

## NAME

xpce - Prolog with graphical user interface (GUI)

## SYNOPSIS

**xpce** prolog-option ...

## DESCRIPTION

XPCE is a language independent library for GUI (Graphical User Interfaces). This manual page discusses XPCE/Prolog: the combination of a Prolog environment and XPCE.

XPCE is an object-oriented engine that can have methods defined in various languages. XPCE has about 150 predefined classes that deal mainly with GUI's.  The object engine of XPE is made available to Prolog using the following predicates:

### Predicates:

- **new(?Ref, +Term)**

  Create an XPCE object from *Term* and bind the object to the reference *Ref.* The functor-name of *Term* describes the class from which to create an instance.  The arguments of *Term* are used as initialisation arguments for the new object.  If the object was created successfully and *Ref* is a variable, *Ref* will be unified with the term @\<RefNumber\>.  If *Ref* is a term of the form @\<Atom\>, this term will serve as a reference for the new object.

  For example *?- new(@p, picture('Hello World').* Creates a graphical window object with title "Hello World".

- **send(+Ref, +Selector, +Args***...)*

  *Ref* is a reference to an existing XPCE object. *Selector* is the name of a (send-)method defined on (the class of) this object and *Args* are terms that describe arguments to be passed to the method.

  *send/\[2-12\]* will convert the arguments to XPCE data objects, resolve the procedure (C-function, Prolog predicate) implementing the method and run the implementation.  If the execution is successful, send *succeeds,* otherwise send *fails.*

  For example *?- send(@p, open, point(400,100)).* opens the picture created above at position 400,100 on the display.

- **get(+Ref, +Selector, +Args ..., -Value)**

  *Ref* is a reference to an existing XPCE object. *Selector* is the name of a (get-)method defined on (the class of) this object and *Args* are terms to provide additional arguments. *get/\[3-13\] works similar as* *send/\[2-12\]* but returns a value rather than succeeding/failing (boolean operation).

  For example *get(@p, height, H).* Unifies *H* with the height of the graphical window.

- **free(+Ref)**

  If *Ref* is a reference to an XPCE object, invoke *send(Ref, free).* to the object.  Otherwise succeed silently.

## SEE ALSO

XPCE's web-home at *http://www.swi.psy.uva.nl/projects/xpce/*

Jan Wielemaker and Anjo Anjewierden *Programming in XPCE/Prolog,* University of Amsterdam, Dept. of Social Science and Informatics (SWI).

Jan Wielemaker *SWI-Prolog 4.0 Reference Manual*. Available from the SWI-Prolog web-home at *http://www.swi.psy.uva.nl/projects/SWI-Prolog/*

The online manual system started with *?- manpce.* or *?- user\_help* on Quintus or SICStus Prolog.

The XPCE WWW home page: *http://swi.psy.uva.nl/projects/xpce/home.html*

[xpce-client(1)](/xpce-client/1.md), [pl(1)](/pl/1.md)

## COPYING

XPCE is distributed under the General Public Licence version 2, also known as the **GPL-2** licence.  The license terms are in the file *COPYING* or on the GNU website at *http://www.gnu.org.*

In a nutshell, you can modify and use XPCE as long as you clearly indicate changes, don't change copyright messages and **distribute the complete source of your work with every binary** **copy or make the source in some other form available for free to your users**

Especially if you do not wish to distribute the source of your work you may wish to consider optaining a *commercial license.* Please visit the SWI-Prolog home-page for details.

## COPYRIGHT

Copyright (c) 1985-2001 University of Amsterdam.  XPCE may be distributed under the terms of the "Simplified BSD license".

## AUTHOR

Jan Wielemaker and Anjo Anjewierden
