PreferencesSectionUI.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. from typing import Dict
  2. from PyQt5 import QtWidgets
  3. from flatcamGUI.preferences.OptionUI import OptionUI
  4. from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
  5. class PreferencesSectionUI(QtWidgets.QWidget):
  6. def __init__(self, **kwargs):
  7. super().__init__(**kwargs)
  8. self.layout = QtWidgets.QHBoxLayout()
  9. self.setLayout(self.layout)
  10. self.groups = self.build_groups()
  11. for group in self.groups:
  12. group.setMinimumWidth(250)
  13. self.layout.addWidget(group)
  14. self.layout.addStretch()
  15. def build_groups(self) -> [OptionsGroupUI]:
  16. return []
  17. def option_dict(self) -> Dict[str, OptionUI]:
  18. result = {}
  19. for group in self.groups:
  20. groupoptions = group.option_dict()
  21. result.update(groupoptions)
  22. return result
  23. def build_tab(self):
  24. tab = QtWidgets.QWidget()
  25. tab_lay = QtWidgets.QVBoxLayout()
  26. tab_lay.setContentsMargins(2, 2, 2, 2)
  27. tab.setLayout(tab_lay)
  28. # Not sure what the point of this is ???
  29. hlay1 = QtWidgets.QHBoxLayout()
  30. hlay1.addStretch()
  31. tab_lay.addLayout(hlay1)
  32. scroll_area = QtWidgets.QScrollArea()
  33. scroll_area.setWidget(self)
  34. self.show()
  35. tab_lay.addWidget(scroll_area)
  36. return tab
  37. def get_tab_id(self) -> str:
  38. raise NotImplementedError
  39. def get_tab_label(self) -> str:
  40. raise NotImplementedError