AutoCompletePrefGroupUI.py 2.6 KB

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