ExcellonPreferencesUI.py 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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.excellon_gen_group.excellon_format_upper_in_entry.returnPressed.connect(self.sync_export)
  25. self.excellon_gen_group.excellon_format_lower_in_entry.returnPressed.connect(self.sync_export)
  26. self.excellon_gen_group.excellon_format_upper_mm_entry.returnPressed.connect(self.sync_export)
  27. self.excellon_gen_group.excellon_format_lower_mm_entry.returnPressed.connect(self.sync_export)
  28. self.excellon_gen_group.excellon_zeros_radio.activated_custom.connect(self.sync_export)
  29. self.excellon_gen_group.excellon_units_radio.activated_custom.connect(self.sync_export)
  30. def build_groups(self) -> [OptionsGroupUI]:
  31. return [
  32. self.excellon_gen_group,
  33. self.excellon_opt_group,
  34. self.excellon_exp_group,
  35. self.excellon_adv_opt_group,
  36. self.excellon_editor_group
  37. ]
  38. def get_tab_id(self):
  39. return "excellon_tab"
  40. def get_tab_label(self):
  41. return _("EXCELLON")
  42. def sync_export(self):
  43. if not self.excellon_gen_group.update_excellon_cb.get_value():
  44. # User has disabled sync.
  45. return
  46. self.excellon_exp_group.zeros_radio.set_value(self.excellon_gen_group.excellon_zeros_radio.get_value() + 'Z')
  47. self.excellon_exp_group.excellon_units_radio.set_value(self.excellon_gen_group.excellon_units_radio.get_value())
  48. if self.excellon_gen_group.excellon_units_radio.get_value().upper() == 'METRIC':
  49. self.excellon_exp_group.format_whole_entry.set_value(self.excellon_gen_group.excellon_format_upper_mm_entry.get_value())
  50. self.excellon_exp_group.format_dec_entry.set_value(self.excellon_gen_group.excellon_format_lower_mm_entry.get_value())
  51. else:
  52. self.excellon_exp_group.format_whole_entry.set_value(self.excellon_gen_group.excellon_format_upper_in_entry.get_value())
  53. self.excellon_exp_group.format_dec_entry.set_value(self.excellon_gen_group.excellon_format_lower_in_entry.get_value())