From: katzj Date: Fri, 8 Jun 2001 14:15:23 +0000 (+0000) Subject: - added python binding for newtListboxClear() for Listbox and CListBox X-Git-Tag: r0-50-25~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=50c9056c561a06ab5ec4265fed0c85264aeb0179;p=thirdparty%2Fnewt.git - added python binding for newtListboxClear() for Listbox and CListBox - let ButtonBars optionally be made of CompactButtons --- diff --git a/newt.spec b/newt.spec index 32e66d3..af7736e 100644 --- a/newt.spec +++ b/newt.spec @@ -1,6 +1,6 @@ Summary: A development library for text mode user interfaces. Name: newt -%define version 0.50.24 +%define version 0.50.25 Version: %{version} Release: 1 Copyright: LGPL @@ -105,6 +105,10 @@ rm -rf $RPM_BUILD_ROOT %endif %changelog +* Fri Jun 8 2001 Jeremy Katz +- added python binding for newtListboxClear() for Listbox and CListBox +- let ButtonBars optionally be made of CompactButtons + * Wed Jun 6 2001 Crutcher Dunnavant - added CListBox python convenience class diff --git a/snack.py b/snack.py index fe330ea..7711af1 100644 --- a/snack.py +++ b/snack.py @@ -96,6 +96,11 @@ class Listbox(Widget): def setCurrent(self, item): self.w.listboxSetCurrent(self.item2key[item]) + def clear(self): + self.key2item = {} + self.item2key = {} + self.w.listboxClear() + def __init__(self, height, scroll = 0, returnExit = 0, width = 0): self.w = _snack.listbox(height, scroll, returnExit) self.key2item = {} @@ -355,7 +360,7 @@ class RadioBar(Grid): class ButtonBar(Grid): - def __init__(self, screen, buttonlist): + def __init__(self, screen, buttonlist, compact = 0): self.list = [] self.hotkeys = {} self.item = 0 @@ -370,7 +375,10 @@ class ButtonBar(Grid): (title, value, hotkey) = blist self.hotkeys[hotkey] = value - b = Button(title) + if compact: + b = CompactButton(title) + else: + b = Button(title) self.list.append((b, value)) self.setField(b, self.item, 0, (1, 0, 1, 0)) self.item = self.item + 1 @@ -615,9 +623,9 @@ class CListBox(Grid): delta = self.col_widths[i] - len(cstr) if delta > 0: if align == None: - a = LEFT - else: - a = align[i] + a = LEFT + else: + a = align[i] if a == LEFT: cstr = cstr + (" " * delta) @@ -664,4 +672,6 @@ class CListBox(Grid): def setCurrent(self, item): self.listbox.setCurrent(item) - + + def clear(self): + self.listbox.clear() diff --git a/snackmodule.c b/snackmodule.c index ca430ac..d42d52b 100644 --- a/snackmodule.c +++ b/snackmodule.c @@ -186,6 +186,7 @@ static PyObject * widgetListboxIns(snackWidget * s, PyObject * args); static PyObject * widgetListboxDel(snackWidget * s, PyObject * args); static PyObject * widgetListboxGet(snackWidget * s, PyObject * args); static PyObject * widgetListboxSet(snackWidget * s, PyObject * args); +static PyObject * widgetListboxClear(snackWidget * s, PyObject * args); static PyObject * widgetTextboxText(snackWidget * s, PyObject * args); static PyObject * widgetCheckboxTreeAddItem(snackWidget * s, PyObject * args); static PyObject * widgetCheckboxTreeGetSel(snackWidget * s, PyObject * args); @@ -209,6 +210,7 @@ static PyMethodDef widgetMethods[] = { { "listboxSetCurrent", (PyCFunction) widgetListboxSet, METH_VARARGS, NULL }, { "listboxSetWidth", (PyCFunction) widgetListboxSetW, METH_VARARGS, NULL }, { "listboxDeleteItem", (PyCFunction) widgetListboxDel, METH_VARARGS, NULL }, + { "listboxClear", (PyCFunction) widgetListboxClear, METH_VARARGS, NULL }, { "scaleSet", (PyCFunction) scaleSet, METH_VARARGS, NULL }, { "checkboxtreeAddItem", (PyCFunction) widgetCheckboxTreeAddItem, METH_VARARGS, NULL }, @@ -1016,6 +1018,16 @@ static PyObject * widgetListboxSetW(snackWidget * s, PyObject * args) { return Py_None; } +static PyObject * widgetListboxClear(snackWidget * s, PyObject * args) { + if (!PyArg_ParseTuple(args, "")) + return NULL; + + newtListboxClear(s->co); + + Py_INCREF(Py_None); + return Py_None; +} + static void emptyDestructor(PyObject * s) { }