From d865e2f1af6eb3d5fb31f9c53088b629a232343f Mon Sep 17 00:00:00 2001 From: wyzula-jan <133381102+wyzula-jan@users.noreply.github.com> Date: Sun, 19 Nov 2023 19:54:57 +0100 Subject: [PATCH] fix: editor.py removed automatic background behind edited text --- bec_widgets/widgets/editor/editor.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/bec_widgets/widgets/editor/editor.py b/bec_widgets/widgets/editor/editor.py index 651b42dc..d913ad0d 100644 --- a/bec_widgets/widgets/editor/editor.py +++ b/bec_widgets/widgets/editor/editor.py @@ -1,5 +1,8 @@ import subprocess +import jedi +from jedi.api import Script +from jedi.api.environment import InterpreterEnvironment import qdarktheme from qtpy.QtCore import Qt from qtpy.QtWidgets import QSplitter @@ -14,6 +17,8 @@ from qtpy.QtWidgets import ( QWidget, ) +from bec_widgets.widgets import ModularToolBar + class ScriptRunnerThread(QThread): outputSignal = Signal(str) @@ -112,13 +117,13 @@ class BECEditor(QWidget): self.editor.setMarginsForegroundColor(textColor) self.editor.setCaretForegroundColor(textColor) self.editor.setCaretLineBackgroundColor(QColor("#44475a")) - self.editor.setPaper(backgroundColor) + self.editor.setPaper(backgroundColor) # Set the background color for the entire paper self.editor.setColor(textColor) - + # # Syntax Highlighting Colors lexer = self.editor.lexer() if lexer: - lexer.setDefaultPaper(backgroundColor) + lexer.setDefaultPaper(backgroundColor) # Set the background color for the text area lexer.setDefaultColor(textColor) lexer.setColor(keywordColor, QsciLexerPython.Keyword) lexer.setColor(stringColor, QsciLexerPython.DoubleQuotedString) @@ -127,6 +132,11 @@ class BECEditor(QWidget): lexer.setColor(classFunctionColor, QsciLexerPython.ClassName) lexer.setColor(classFunctionColor, QsciLexerPython.FunctionMethodName) + # Set the style for all text to have a transparent background + # TODO find better way how to do it! + for style in range(128): # QsciScintilla supports 128 styles by default + self.lexer.setPaper(backgroundColor, style) + def runScript(self): script = self.editor.text() self.scriptRunnerThread = ScriptRunnerThread(script) @@ -156,8 +166,6 @@ class BECEditor(QWidget): if __name__ == "__main__": - from bec_widgets.widgets.toolbar.toolbar import ModularToolBar, OpenFileAction, SaveFileAction - app = QApplication([]) qdarktheme.setup_theme("auto")