ExcellonPreferencesUI.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
  2. from flatcamGUI.preferences.PreferencesSectionUI import PreferencesSectionUI
  3. from flatcamGUI.preferences.excellon.ExcellonEditorPrefGroupUI import ExcellonEditorPrefGroupUI
  4. from flatcamGUI.preferences.excellon.ExcellonExpPrefGroupUI import ExcellonExpPrefGroupUI
  5. from flatcamGUI.preferences.excellon.ExcellonAdvOptPrefGroupUI import ExcellonAdvOptPrefGroupUI
  6. from flatcamGUI.preferences.excellon.ExcellonOptPrefGroupUI import ExcellonOptPrefGroupUI
  7. from flatcamGUI.preferences.excellon.ExcellonGenPrefGroupUI import ExcellonGenPrefGroupUI
  8. import gettext
  9. import FlatCAMTranslation as fcTranslate
  10. import builtins
  11. fcTranslate.apply_language('strings')
  12. if '_' not in builtins.__dict__:
  13. _ = gettext.gettext
  14. class ExcellonPreferencesUI(PreferencesSectionUI):
  15. def __init__(self, decimals, **kwargs):
  16. self.decimals = decimals
  17. self.excellon_gen_group = ExcellonGenPrefGroupUI(decimals=self.decimals)
  18. # FIXME: remove the need for external access to excellon_opt_group
  19. self.excellon_opt_group = ExcellonOptPrefGroupUI(decimals=self.decimals)
  20. self.excellon_exp_group = ExcellonExpPrefGroupUI(decimals=self.decimals)
  21. self.excellon_adv_opt_group = ExcellonAdvOptPrefGroupUI(decimals=self.decimals)
  22. self.excellon_editor_group = ExcellonEditorPrefGroupUI(decimals=self.decimals)
  23. super().__init__(**kwargs)
  24. self.init_sync_export()
  25. def build_groups(self) -> [OptionsGroupUI]:
  26. return [
  27. self.excellon_gen_group,
  28. self.excellon_opt_group,
  29. self.excellon_exp_group,
  30. self.excellon_adv_opt_group,
  31. self.excellon_editor_group
  32. ]
  33. def get_tab_id(self):
  34. return "excellon_tab"
  35. def get_tab_label(self):
  36. return _("EXCELLON")
  37. def init_sync_export(self):
  38. self.option_dict()["excellon_update"].get_field().stateChanged.connect(self.sync_export)
  39. self.option_dict()["excellon_format_upper_in"].get_field().returnPressed.connect(self.sync_export)
  40. self.option_dict()["excellon_format_lower_in"].get_field().returnPressed.connect(self.sync_export)
  41. self.option_dict()["excellon_format_upper_mm"].get_field().returnPressed.connect(self.sync_export)
  42. self.option_dict()["excellon_format_lower_mm"].get_field().returnPressed.connect(self.sync_export)
  43. self.option_dict()["excellon_zeros"].get_field().activated_custom.connect(self.sync_export)
  44. self.option_dict()["excellon_units"].get_field().activated_custom.connect(self.sync_export)
  45. def sync_export(self):
  46. if not self.option_dict()["excellon_update"].get_field().get_value():
  47. # User has disabled sync.
  48. return
  49. self.excellon_exp_group.zeros_radio.set_value(self.option_dict()["excellon_zeros"].get_field().get_value() + 'Z')
  50. self.excellon_exp_group.excellon_units_radio.set_value(self.option_dict()["excellon_units"].get_field().get_value())
  51. if self.option_dict()["excellon_units"].get_field().get_value().upper() == 'METRIC':
  52. self.excellon_exp_group.format_whole_entry.set_value(self.option_dict()["excellon_format_upper_mm"].get_field().get_value())
  53. self.excellon_exp_group.format_dec_entry.set_value(self.option_dict()["excellon_format_lower_mm"].get_field().get_value())
  54. else:
  55. self.excellon_exp_group.format_whole_entry.set_value(self.option_dict()["excellon_format_upper_in"].get_field().get_value())
  56. self.excellon_exp_group.format_dec_entry.set_value(self.option_dict()["excellon_format_lower_in"].get_field().get_value())