campy.private.backends.backend module

Load a campy graphical backend.

The default graphical backend is Tk, but others are available in varying degrees of support.

The available backends are:

  • Tk (default): Cross-platform graphics and widget library.
  • JBE: Text-based communication to a Java backend: acm.jar. Requires Java.

This structure was modelled off of matplotlib’s - for more information, see:

There are two ways to configure your backend. If there’s a conflict, the last one in the list will be used.

1. Setting the CAMPY_BACKEND environmental variable, either for your current shell or for a single script:

$ export CAMPY_BACKEND="Tk"
$ python

$ CAMPY_BACKEND="tk" python
  1. If your script depends on a specific backend you can call use():

    $ import campy
    $ campy.use('tk')

The use() function must be invoked before importing any other campy modules. Calling use after another campy module has been imported will have no effect. If you are building library code, you should avoid explicitly calling use() unless absolutely necessary because your users will have to change the code if they want to use a different backend.

Note: Backend name specifications are not case-sensitive, e.g. ‘Tk’ and ‘tk’ are equivalent.