From: ewt Date: Thu, 26 Aug 1999 23:18:06 +0000 (+0000) Subject: 1) added hotkey's to grid forms X-Git-Tag: r0-50~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f5ec403365f337c3662e322535cf54ae24ac3d8d;p=thirdparty%2Fnewt.git 1) added hotkey's to grid forms 2) set listbox position by key, not index --- diff --git a/snack.py b/snack.py index 90dc3ec..0392776 100644 --- a/snack.py +++ b/snack.py @@ -82,8 +82,8 @@ class Listbox(Widget): def current(self): return self.key2item[self.w.listboxGetCurrent()] - def setCurrent(self, index): - self.w.listboxSetCurrent(index) + def setCurrent(self, item): + self.w.listboxSetCurrent(self.item2key[item]) def __init__(self, height, scroll = 0, returnExit = 0, width = 0): self.w = _snack.listbox(height, scroll, returnExit) @@ -372,6 +372,9 @@ class GridForm(Grid): self.screen.popWindow() return result + def addHotKey(self, keyname): + self.form.addHotKey(keyname) + def create(self): if not self.form_created: self.place(1,1) @@ -438,6 +441,11 @@ def ListboxChoiceWindow(screen, title, text, items, text = item key = count + if (count == default): + default = key + elif (count == item): + default = key + l.append(text, key) count = count + 1 diff --git a/snackmodule.c b/snackmodule.c index 9999fb0..d0be071 100644 --- a/snackmodule.c +++ b/snackmodule.c @@ -861,7 +861,7 @@ static PyObject * widgetListboxSet(snackWidget * s, PyObject * args) { if (!PyArg_ParseTuple(args, "i", &index)) return NULL; - newtListboxSetCurrent(s->co, index); + newtListboxSetCurrentByKey(s->co, index); Py_INCREF(Py_None); return Py_None;