]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
added code to update label text
authorewt <ewt>
Fri, 30 Apr 1999 21:24:47 +0000 (21:24 +0000)
committerewt <ewt>
Fri, 30 Apr 1999 21:24:47 +0000 (21:24 +0000)
snack.py
snackmodule.c

index 96a3aa4366c02391a6d761a53ccd6cc858fb2fe7..f5d407d863bc7646ae9d12e1373dfa9e7f48e092 100644 (file)
--- 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)
 
index 26c37079b399b5b940bf9cc3e46e885e1dd65a7c..7a897fba153d435e3abca8168e6db4679ebda0e2 100644 (file)
@@ -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;