You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.2 KiB

  1. import wx
  2. from functools import reduce
  3. from gooey.gui.components.widgets.core.text_input import MultilineTextInput
  4. from gooey.gui.components.widgets.textfield import TextField
  5. from gooey.gui.components.widgets.bases import TextContainer
  6. from gooey.gui import formatters
  7. class Textarea(TextContainer):
  8. def getWidget(self, parent, *args, **options):
  9. widgetHeight = self._options.get('height', -1)
  10. return wx.TextCtrl(
  11. parent=parent,
  12. size=(-1, widgetHeight),
  13. style=self.getModifiers()
  14. )
  15. def getModifiers(self):
  16. readonly = (wx.TE_READONLY
  17. if self._options.get('readonly', False)
  18. # using TE_MUTLI as a safe OR-able no-op value
  19. else wx.TE_MULTILINE)
  20. return reduce(lambda acc, val: acc | val, [wx.TE_MULTILINE, readonly])
  21. def getWidgetValue(self):
  22. return self.widget.GetValue()
  23. def setValue(self, value):
  24. self.widget.Clear()
  25. self.widget.AppendText(str(value))
  26. self.widget.SetInsertionPoint(0)
  27. def formatOutput(self, metatdata, value):
  28. return formatters.general(metatdata, value)