A Graphical User Interface for Basilisk View

    The interactive version of Basilisk View relies on a client/server model. The Basilisk View server can run on a distant system (for example the large parallel machine on which the Basilisk runs are done), or on the local system.

    A Basilisk View client running on the local system then sends “commands” to the server and receives in return a stream of PPM images containing the updated views.

    The commands are just function calls, sent as a stream of text by the client, using the same syntax as for the load() function.

    The following Python code implements a simple Graphical User Interface (GUI) client using this model.

    The client standard input should be connected (typically through Unix pipes or named pipes) to the standard output of the server. Conversely, the client standard output should be connected to the server’s standard input. For convenience, this is typically done using the bview shell script.

    The client then creates a Tkinter window and waits both for user interaction (using the mouse or keyboard) and for images sent by the server on input. This is done concurrently using two threads.

    User interaction is converted to Basilisk View commands which are written to standard output, and thus sent to the server, which in turn responds with images which are used to refresh the Tkinter window.

    Summary of controls

    • Left-mouse button + drag: rotate camera.
    • Right-mouse button + drag: translate camera.
    • Center-mouse button + drag: zoom.
    • Mouse wheel: zoom.
    • ‘+’ or ‘-’ keys: zoom.
    • ‘B’ key: calls box().
    • ‘c’ key: calls clear().
    • ‘l’, ‘r’, ‘t’, ‘b’, ‘f’, ‘z’, ‘i’ keys: changes view to ‘left’, ‘right’, ‘top’, ‘bottom’, ‘front’, ‘back’, ‘iso’ respectively.
    • Right/left arrow keys: rotates right/left by 3 degrees.
    • Up/down arrow keys: rotates up/down by 3 degrees.
    • ‘q’ key: quits.
    • ‘<’ or ‘>’ keys: decrease or increase minimum delay between screen refreshes.
    • ‘1’ and ‘4’: set the number of samples (1 fast/coarse, 4 slow/fine).
    • ‘8’ and ‘9’: rotate view clockwise (resp. anti-clockwise).

    User customisation

    If it exists, the script will import the file $HOME/ This can be used to customise the interface. For example, if one wants to define a new keyboard mapping, one could use the following in $HOME/

    from bview import keymap
    keymap["'v'"] = 'draw_vof("f")\n'


    The current version will work with python2.7 but not python3.x. Besides Tkinter, the program also uses the ImageTk extension of the Python Imaging Library (PIL).

    Debian-like systems (Debian, Ubuntu etc.)

    The required dependencies can be installed easily using:

    sudo apt-get install python-pil.imagetk

    or for older Debian versions (\leq 7):

    sudo apt-get install python-imaging

    Mac OSX

    To check whether Tkinter is correctly installed on your system, do:

    python -m Tkinter

    If a window pops up with a click button, then it works. Otherwise you will need to install it.

    It is recommended to reinstall python as well. See:

    You may also need to install the PIL (or Pillow) module. This can be done using:

    sudo easy_install pip
    pip install pillow


    from Tkinter import Tk, mainloop
    from sys import stdout, stderr
    from bview import BCanvas
    # Try user customization
    from os.path import expanduser
    import imp
        imp.load_source('userinit', expanduser("~/"))
    except IOError:
    root = Tk()
    root.title ('bview')
    root.canvas = BCanvas (root, stdout)
    stdout = stderr
    except (KeyboardInterrupt, SystemExit):