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.

32 lines
920 B

  1. import wx
  2. from gooey.gui import formatters
  3. from gooey.gui.components.widgets.bases import TextContainer
  4. class Listbox(TextContainer):
  5. def getWidget(self, parent, *args, **options):
  6. height = self._options.get('height', 60)
  7. return wx.ListBox(
  8. parent=parent,
  9. choices=self._meta['choices'],
  10. size=(-1, height),
  11. style=wx.LB_MULTIPLE
  12. )
  13. def setOptions(self, options):
  14. self.widget.Clear()
  15. for option in options:
  16. self.widget.Append(option)
  17. def setValue(self, values):
  18. for string in values:
  19. self.widget.SetStringSelection(string)
  20. def getWidgetValue(self):
  21. return [self.widget.GetString(index)
  22. for index in self.widget.GetSelections()]
  23. def formatOutput(self, metadata, value):
  24. return formatters.listbox(metadata, value)