From 06fdc82f60a35ec3e2be34e1ace7431643a61499 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Sat, 31 May 2014 15:26:18 +0200 Subject: Do not traceback if the server does not oprived options for list fields --- src/windows/data_forms.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/windows/data_forms.py b/src/windows/data_forms.py index 1fa3d031..0b27291c 100644 --- a/src/windows/data_forms.py +++ b/src/windows/data_forms.py @@ -227,9 +227,10 @@ class ListMultiWin(FieldInput, Win): self.addstr(0, 0, '←') if self.val_pos < len(self.options)-1: self.addstr(0, self.width-1, '→') - option = self.options[self.val_pos] - self.addstr(0, self.width//2-len(option)//2, option[0]['label']) - self.addstr(0, 2, '✔' if option[1] else '☐') + if self.options: + option = self.options[self.val_pos] + self.addstr(0, self.width//2-len(option)//2, option[0]['label']) + self.addstr(0, 2, '✔' if option[1] else '☐') self._win.attroff(to_curses_attr(self.color)) self._refresh() @@ -274,8 +275,9 @@ class ListSingleWin(FieldInput, Win): self.addstr(0, 0, '←') if self.val_pos < len(self.options)-1: self.addstr(0, self.width-1, '→') - option = self.options[self.val_pos]['label'] - self.addstr(0, self.width//2-len(option)//2, option) + if self.options: + option = self.options[self.val_pos]['label'] + self.addstr(0, self.width//2-len(option)//2, option) self._win.attroff(to_curses_attr(self.color)) self._refresh() -- cgit v1.2.3