- Label(self,text) : create label
- setText(self,text) : change text.
+ - setColors(self, colorset) : change individual colors
"""
def setText(self, text):
self.w.labelText(text)
def __init__(self, text):
self.w = _snack.label(text)
+ def setColors(self, colorset):
+ self.w.labelSetColors(colorset)
+
class Scale(Widget):
"""A Scale (progress bar).
return _snack.refresh()
def setColor(self, colorset, fg, bg):
- return _snack.setcolor(colorsets[colorset], fg, bg)
+ if colorset in colorsets:
+ return _snack.setcolor(colorsets[colorset], fg, bg)
+ else:
+ # assume colorset is an integer for the custom color set
+ return _snack.setcolor(colorset, fg, bg)
def reflow(text, width, flexDown = 5, flexUp = 5):
""" returns a tuple of the wrapped text, the actual width, and the actual height
def clear(self):
self.listbox.clear()
+
+def customColorset(x):
+ return 30 + x
static void widgetDestructor(PyObject * s);
static PyObject * widgetEntrySetValue(snackWidget * s, PyObject * args);
static PyObject * widgetLabelText(snackWidget * s, PyObject * args);
+static PyObject * widgetLabelSetColors(snackWidget * s, PyObject * args);
static PyObject * widgetListboxSetW(snackWidget * s, PyObject * args);
static PyObject * widgetListboxAdd(snackWidget * s, PyObject * args);
static PyObject * widgetListboxIns(snackWidget * s, PyObject * args);
static PyMethodDef widgetMethods[] = {
{ "setCallback", (PyCFunction) widgetAddCallback, METH_VARARGS, NULL },
+ { "labelSetColors", (PyCFunction) widgetLabelSetColors, METH_VARARGS, NULL },
{ "labelText", (PyCFunction) widgetLabelText, METH_VARARGS, NULL },
{ "textboxText", (PyCFunction) widgetTextboxText, METH_VARARGS, NULL },
{ "textboxHeight", (PyCFunction) widgetTextboxHeight, METH_VARARGS, NULL },
return Py_None;
}
+static PyObject * widgetLabelSetColors(snackWidget * s, PyObject * args) {
+ int colorset;
+
+ if (!PyArg_ParseTuple(args, "i", &colorset)) return NULL;
+
+ newtLabelSetColors(s->co, colorset);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
static PyObject * widgetTextboxText(snackWidget * s, PyObject * args) {
char * text;