OptionsGroupUI.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # ##########################################################
  2. # FlatCAM: 2D Post-processing for Manufacturing #
  3. # File by: David Robertson (c) #
  4. # Date: 5/2020 #
  5. # License: MIT Licence #
  6. # ##########################################################
  7. from typing import Dict
  8. from PyQt5 import QtWidgets
  9. from PyQt5.QtCore import QSettings
  10. import gettext
  11. import appTranslation as fcTranslate
  12. import builtins
  13. from appGUI.preferences.OptionUI import OptionUI
  14. fcTranslate.apply_language('strings')
  15. if '_' not in builtins.__dict__:
  16. _ = gettext.gettext
  17. settings = QSettings("Open Source", "FlatCAM")
  18. if settings.contains("machinist"):
  19. machinist_setting = settings.value('machinist', type=int)
  20. else:
  21. machinist_setting = 0
  22. class OptionsGroupUI(QtWidgets.QGroupBox):
  23. app = None
  24. def __init__(self, title, parent=None):
  25. # QtGui.QGroupBox.__init__(self, title, parent=parent)
  26. super(OptionsGroupUI, self).__init__()
  27. self.setStyleSheet("""
  28. QGroupBox
  29. {
  30. font-size: 16px;
  31. font-weight: bold;
  32. }
  33. """)
  34. self.layout = QtWidgets.QVBoxLayout()
  35. self.setLayout(self.layout)
  36. def option_dict(self) -> Dict[str, OptionUI]:
  37. # FIXME!
  38. return {}
  39. class OptionsGroupUI2(OptionsGroupUI):
  40. def __init__(self, **kwargs):
  41. super().__init__(**kwargs)
  42. self.grid = QtWidgets.QGridLayout()
  43. self.layout.addLayout(self.grid)
  44. self.grid.setColumnStretch(0, 0)
  45. self.grid.setColumnStretch(1, 1)
  46. self.options = self.build_options()
  47. row = 0
  48. for option in self.options:
  49. row += option.add_to_grid(grid=self.grid, row=row)
  50. self.layout.addStretch()
  51. def build_options(self) -> [OptionUI]:
  52. return []
  53. def option_dict(self) -> Dict[str, OptionUI]:
  54. result = {}
  55. for optionui in self.options:
  56. result[optionui.option] = optionui
  57. return result