Brian Victor wrote:
Still hoping someone will hop in with "just use this curses extension"
or "you can write a wrapper around that one function and integrate it
with python's curses like this." But thanks for the input, anyway!
I guess that someone is me. I love replying to my own posts...
I just hacked this bit of code up and it seems to do the trick.
importing usedefault and calling usedefault.use_default_colors() sets
color pair 0 to use the default colors for the terminal. This allows
translucency on terminals that support it. The packaging could use some
work, but the following should be enough to get future readers going.
This is the first C extension I've written, and it's almost straight
from the docs. If anyone has any pointers, I'd be happy to hear them.
usedefault.c
#v+
#include <Python.h>
#include <ncurses.h>
static PyObject *
pyuse_default_colors(PyObject *self, PyObject *args)
{
use_default_colors();
Py_INCREF(Py_None);
return Py_None;
}
static PyMethodDef SpamMethods[] = {
{"use_default_colors", pyuse_default_colors, METH_VARARGS,
"Use Default Colors."},
{NULL, NULL, 0, NULL} /* Sentinel */
};
/* PyMODINIT_FUNC */
/* The docs say to use the above, but it doesn't exist in my copy of
* Python.h. */
void initusedefault()
{
(void) Py_InitModule("usedefault", SpamMethods);
}
#v-
setup.py
#v+
from distutils.core import setup, Extension
module1 = Extension('usedefault',
libraries = ["ncurses"],
sources = ['usedefault.c'])
setup (name = 'usedefault',
version = '1.0',
description = 'Use default colors in curses',
ext_modules = [module1])
#v-
--
Brian