0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-14 11:41:49 +02:00

fix: editor.py removed automatic background behind edited text

This commit is contained in:
wyzula-jan
2023-11-19 19:54:57 +01:00
parent c70ddb3cb1
commit d865e2f1af

View File

@ -1,5 +1,8 @@
import subprocess import subprocess
import jedi
from jedi.api import Script
from jedi.api.environment import InterpreterEnvironment
import qdarktheme import qdarktheme
from qtpy.QtCore import Qt from qtpy.QtCore import Qt
from qtpy.QtWidgets import QSplitter from qtpy.QtWidgets import QSplitter
@ -14,6 +17,8 @@ from qtpy.QtWidgets import (
QWidget, QWidget,
) )
from bec_widgets.widgets import ModularToolBar
class ScriptRunnerThread(QThread): class ScriptRunnerThread(QThread):
outputSignal = Signal(str) outputSignal = Signal(str)
@ -112,13 +117,13 @@ class BECEditor(QWidget):
self.editor.setMarginsForegroundColor(textColor) self.editor.setMarginsForegroundColor(textColor)
self.editor.setCaretForegroundColor(textColor) self.editor.setCaretForegroundColor(textColor)
self.editor.setCaretLineBackgroundColor(QColor("#44475a")) 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) self.editor.setColor(textColor)
#
# Syntax Highlighting Colors # Syntax Highlighting Colors
lexer = self.editor.lexer() lexer = self.editor.lexer()
if lexer: if lexer:
lexer.setDefaultPaper(backgroundColor) lexer.setDefaultPaper(backgroundColor) # Set the background color for the text area
lexer.setDefaultColor(textColor) lexer.setDefaultColor(textColor)
lexer.setColor(keywordColor, QsciLexerPython.Keyword) lexer.setColor(keywordColor, QsciLexerPython.Keyword)
lexer.setColor(stringColor, QsciLexerPython.DoubleQuotedString) lexer.setColor(stringColor, QsciLexerPython.DoubleQuotedString)
@ -127,6 +132,11 @@ class BECEditor(QWidget):
lexer.setColor(classFunctionColor, QsciLexerPython.ClassName) lexer.setColor(classFunctionColor, QsciLexerPython.ClassName)
lexer.setColor(classFunctionColor, QsciLexerPython.FunctionMethodName) 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): def runScript(self):
script = self.editor.text() script = self.editor.text()
self.scriptRunnerThread = ScriptRunnerThread(script) self.scriptRunnerThread = ScriptRunnerThread(script)
@ -156,8 +166,6 @@ class BECEditor(QWidget):
if __name__ == "__main__": if __name__ == "__main__":
from bec_widgets.widgets.toolbar.toolbar import ModularToolBar, OpenFileAction, SaveFileAction
app = QApplication([]) app = QApplication([])
qdarktheme.setup_theme("auto") qdarktheme.setup_theme("auto")