summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-05-31 15:26:18 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-05-31 15:27:03 +0200
commit06fdc82f60a35ec3e2be34e1ace7431643a61499 (patch)
tree275f2fbd76d8f5541597e2edebdd1aebd4f467af
parent7049fe7c2157f2974c526927a683bcd4b4317d80 (diff)
downloadpoezio-06fdc82f60a35ec3e2be34e1ace7431643a61499.tar.gz
poezio-06fdc82f60a35ec3e2be34e1ace7431643a61499.tar.bz2
poezio-06fdc82f60a35ec3e2be34e1ace7431643a61499.tar.xz
poezio-06fdc82f60a35ec3e2be34e1ace7431643a61499.zip
Do not traceback if the server does not oprived options for list fields
-rw-r--r--src/windows/data_forms.py12
1 files changed, 7 insertions, 5 deletions
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()