Просмотр исходного кода

- working on adding line numbers to the TextPlainEdit

Marius Stanciu 6 лет назад
Родитель
Сommit
0aff3a6d4c
4 измененных файлов с 9 добавлено и 9 удалено
  1. 2 2
      FlatCAMObj.py
  2. 1 0
      README.md
  3. 3 1
      flatcamEditors/FlatCAMTextEditor.py
  4. 3 6
      flatcamGUI/GUIElements.py

+ 2 - 2
FlatCAMObj.py

@@ -5072,13 +5072,13 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                     with self.app.proc_container.new(_("Generating CNC Code")):
                         if app_obj.new_object("cncjob", outname, job_init_single_geometry, plot=plot) != 'fail':
                             app_obj.inform.emit('[success] %s: %s' %
-                                                (_("CNCjob created")), outname)
+                                                (_("CNCjob created"), outname))
                             app_obj.progress.emit(100)
                 else:
                     with self.app.proc_container.new(_("Generating CNC Code")):
                         if app_obj.new_object("cncjob", outname, job_init_multi_geometry) != 'fail':
                             app_obj.inform.emit('[success] %s: %s' %
-                                                (_("CNCjob created")), outname)
+                                                (_("CNCjob created"), outname))
                             app_obj.progress.emit(100)
 
             # Create a promise with the name

+ 1 - 0
README.md

@@ -13,6 +13,7 @@ CAD program, and create G-Code for Isolation routing.
 
 - Tool Fiducials - added GUI in Preferences and entries in self.defaults dict
 - Tool Fiducials - updated the source_file object for the modified Gerber files
+- working on adding line numbers to the TextPlainEdit
 
 21.11.2019
 

+ 3 - 1
flatcamEditors/FlatCAMTextEditor.py

@@ -40,7 +40,9 @@ class TextEditor(QtWidgets.QWidget):
         self.t_frame.setLayout(self.work_editor_layout)
 
         if plain_text:
-            self.code_editor = FCPlainTextAreaExtended()
+            self.editor_class = FCTextAreaLineNumber()
+            self.code_editor = self.editor_class.edit
+
             stylesheet = """
                             QPlainTextEdit { selection-background-color:yellow;
                                              selection-color:black;

+ 3 - 6
flatcamGUI/GUIElements.py

@@ -2341,7 +2341,7 @@ class MyCompleter(QCompleter):
         return self.lastSelected
 
 
-class LNTextEdit(QtWidgets.QFrame):
+class FCTextAreaLineNumber(QtWidgets.QFrame):
     textChanged = QtCore.pyqtSignal()
 
     class NumberBar(QtWidgets.QWidget):
@@ -2372,14 +2372,14 @@ class LNTextEdit(QtWidgets.QFrame):
                 # selected.
                 self.update()
 
-    class PlainTextEdit(QtWidgets.QPlainTextEdit):
+    class PlainTextEdit(FCPlainTextAreaExtended):
         """
         TextEdit with line numbers and highlight
         From here: https://nachtimwald.com/2009/08/19/better-qplaintextedit-with-line-numbers/
         """
 
         def __init__(self, *args):
-            QtWidgets.QPlainTextEdit.__init__(self, *args)
+            FCPlainTextAreaExtended.__init__(self, *args)
 
             #self.setFrameStyle(QFrame.NoFrame)
 
@@ -2453,9 +2453,6 @@ class LNTextEdit(QtWidgets.QFrame):
         self.edit.blockCountChanged.connect(self.number_bar.adjustWidth)
         self.edit.updateRequest.connect(self.number_bar.updateContents)
 
-    def set_model_data(self, kwd):
-        pass
-
     def getText(self):
         return str(self.edit.toPlainText())