curses and use_default_colors()
A.M. Kuchling
amk at amk.ca
Thu Jul 31 17:51:07 EDT 2003
On Wed, 30 Jul 2003 17:34:29 GMT,
Brian Victor <bhv1 at psu.edu> wrote:
> 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 */
Use METH_NOARGS instead of METH_VARARGS; as written, this code will accept
any number of arguments to the Python use_default_colors() method and not
raise any error. An alternative would be to leave METH_VARARGS and put "if
(!PyArg_NoArgs(args)) return NULL;" in pyuse_default_colors(); this would
work with older versions of Python at the cost of being slightly slower.
I'll add this function to the curses module, so at least it'll be in 2.4;
thanks for writing it. Anyone know if it's possible to test it on MacOS X?
Does the Terminal support transparency?
--amk
> };
>
> /* 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-
>
More information about the Python-list
mailing list