AutoCompletePrefGroupUI.py 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. from PyQt5 import QtWidgets, QtGui
  2. from PyQt5.QtCore import QSettings
  3. from AppGUI.GUIElements import FCButton, FCTextArea, FCEntry
  4. from AppGUI.preferences.OptionsGroupUI import OptionsGroupUI
  5. import gettext
  6. import AppTranslation as fcTranslate
  7. import builtins
  8. fcTranslate.apply_language('strings')
  9. if '_' not in builtins.__dict__:
  10. _ = gettext.gettext
  11. settings = QSettings("Open Source", "FlatCAM")
  12. if settings.contains("machinist"):
  13. machinist_setting = settings.value('machinist', type=int)
  14. else:
  15. machinist_setting = 0
  16. class AutoCompletePrefGroupUI(OptionsGroupUI):
  17. def __init__(self, decimals=4, parent=None):
  18. # OptionsGroupUI.__init__(self, "Gerber File associations Preferences", parent=None)
  19. super().__init__(self, parent=parent)
  20. self.setTitle(str(_("Autocompleter Keywords")))
  21. self.decimals = decimals
  22. self.restore_btn = FCButton(_("Restore"))
  23. self.restore_btn.setToolTip(_("Restore the autocompleter keywords list to the default state."))
  24. self.del_all_btn = FCButton(_("Delete All"))
  25. self.del_all_btn.setToolTip(_("Delete all autocompleter keywords from the list."))
  26. hlay0 = QtWidgets.QHBoxLayout()
  27. self.layout.addLayout(hlay0)
  28. hlay0.addWidget(self.restore_btn)
  29. hlay0.addWidget(self.del_all_btn)
  30. # ## Gerber associations
  31. self.grb_list_label = QtWidgets.QLabel("<b>%s:</b>" % _("Keywords list"))
  32. self.grb_list_label.setToolTip(
  33. _("List of keywords used by\n"
  34. "the autocompleter in FlatCAM.\n"
  35. "The autocompleter is installed\n"
  36. "in the Code Editor and for the Tcl Shell.")
  37. )
  38. self.layout.addWidget(self.grb_list_label)
  39. qsettings = QSettings("Open Source", "FlatCAM")
  40. if qsettings.contains("textbox_font_size"):
  41. tb_fsize = qsettings.value('textbox_font_size', type=int)
  42. else:
  43. tb_fsize = 10
  44. self.kw_list_text = FCTextArea()
  45. self.kw_list_text.setReadOnly(True)
  46. # self.grb_list_text.sizeHint(custom_sizehint=150)
  47. self.layout.addWidget(self.kw_list_text)
  48. font = QtGui.QFont()
  49. font.setPointSize(tb_fsize)
  50. self.kw_list_text.setFont(font)
  51. self.kw_label = QtWidgets.QLabel('%s:' % _("Extension"))
  52. self.kw_label.setToolTip(_("A keyword to be added or deleted to the list."))
  53. self.kw_entry = FCEntry()
  54. hlay1 = QtWidgets.QHBoxLayout()
  55. self.layout.addLayout(hlay1)
  56. hlay1.addWidget(self.kw_label)
  57. hlay1.addWidget(self.kw_entry)
  58. self.add_btn = FCButton(_("Add keyword"))
  59. self.add_btn.setToolTip(_("Add a keyword to the list"))
  60. self.del_btn = FCButton(_("Delete keyword"))
  61. self.del_btn.setToolTip(_("Delete a keyword from the list"))
  62. hlay2 = QtWidgets.QHBoxLayout()
  63. self.layout.addLayout(hlay2)
  64. hlay2.addWidget(self.add_btn)
  65. hlay2.addWidget(self.del_btn)
  66. # self.layout.addStretch()