How to run 'ufw' without interactive mode?

Use

ufw --force enable

You may want to have a look at the Gufw source code, it's written in Python. At least in Ubuntu 14.10 the calls to ufw are in the file gufw/model/ufw_backend.py.

You can download the source code using

apt-get source gufw