comparison sat_frontends/jp/xmlui_manager.py @ 2939:18a98a541f7a

jp (xmlui manager): basic handling of multi-lines text in TextBoxWidget
author Goffi <goffi@goffi.org>
date Fri, 03 May 2019 20:49:27 +0200
parents 442ab697f831
children 5d13d357896c
comparison
equal deleted inserted replaced
2938:48985ef7682f 2939:18a98a541f7a
234 type = u"jid_input" 234 type = u"jid_input"
235 235
236 236
237 class TextBoxWidget(xmlui_base.TextWidget, StringWidget): 237 class TextBoxWidget(xmlui_base.TextWidget, StringWidget):
238 type = u"textbox" 238 type = u"textbox"
239 # TODO: use a more advanced input method
240
241 def show(self):
242 self.verboseName()
243 if self.read_only:
244 self.disp(self.value)
245 else:
246 if self.value:
247 self.disp(A.color(C.A_HEADER, u"↓ current value ↓\n", A.FG_CYAN, self.value,
248 ""))
249
250 values = []
251 while True:
252 try:
253 if not values:
254 line = raw_input(A.color(C.A_HEADER, u"[Ctrl-D to finish]> "))
255 else:
256 line = raw_input()
257 values.append(line)
258 except EOFError:
259 break
260
261 self.value = u'\n'.join(values).rstrip()
239 262
240 263
241 class XHTMLBoxWidget(xmlui_base.XHTMLBoxWidget, StringWidget): 264 class XHTMLBoxWidget(xmlui_base.XHTMLBoxWidget, StringWidget):
242 type = u"xhtmlbox" 265 type = u"xhtmlbox"
243 266