From: ewt Date: Fri, 30 Apr 1999 21:24:47 +0000 (+0000) Subject: added code to update label text X-Git-Tag: r0-50~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=522d350029b80465145513a531b6db5c2000e748;p=thirdparty%2Fnewt.git added code to update label text --- diff --git a/snack.py b/snack.py index 96a3aa4..f5d407d 100644 --- a/snack.py +++ b/snack.py @@ -94,6 +94,9 @@ class TextboxReflowed(Textbox): class Label(Widget): + def setText(self, text): + self.w.labelText(text) + def __init__(self, text): self.w = _snack.label(text) diff --git a/snackmodule.c b/snackmodule.c index 26c3707..7a897fb 100644 --- a/snackmodule.c +++ b/snackmodule.c @@ -145,6 +145,7 @@ struct snackWidget_s { static PyObject * widgetAddCallback(snackWidget * s, PyObject * args); static PyObject * widgetGetAttr(PyObject * s, char * name); static PyObject * widgetEntrySetValue(snackWidget * s, PyObject * args); +static PyObject * widgetLabelText(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); @@ -153,6 +154,7 @@ static PyObject * widgetListboxGet(snackWidget * s, PyObject * args); static PyMethodDef widgetMethods[] = { { "setCallback", (PyCFunction) widgetAddCallback, METH_VARARGS, NULL }, + { "labelText", (PyCFunction) widgetLabelText, METH_VARARGS, NULL }, { "entrySetValue", (PyCFunction) widgetEntrySetValue, METH_VARARGS, NULL }, { "listboxAddItem", (PyCFunction) widgetListboxAdd, METH_VARARGS, NULL }, { "listboxInsertItem", (PyCFunction) widgetListboxIns, METH_VARARGS, NULL }, @@ -375,6 +377,17 @@ static snackWidget * labelWidget(PyObject * s, PyObject * args) { return widget; } +static PyObject * widgetLabelText(snackWidget * s, PyObject * args) { + char * label; + + if (!PyArg_ParseTuple(args, "s", &label)) return NULL; + + newtLabelSetText(s->co, label); + + Py_INCREF(Py_None); + return Py_None; +} + static snackWidget * listboxWidget(PyObject * s, PyObject * args) { snackWidget * widget; int height;