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:
@ -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")
|
||||
|
||||
|
Reference in New Issue
Block a user