mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 03:31:50 +02:00
fix(theme): fixed theme access for themecontainer
This commit is contained in:
@ -71,7 +71,7 @@ class BECWidget(BECConnector):
|
||||
if theme is None:
|
||||
qapp = QApplication.instance()
|
||||
if hasattr(qapp, "theme"):
|
||||
theme = qapp.theme["theme"]
|
||||
theme = qapp.theme.theme
|
||||
else:
|
||||
theme = "dark"
|
||||
self.apply_theme(theme)
|
||||
|
@ -8,14 +8,14 @@ import pyqtgraph as pg
|
||||
from bec_qthemes._os_appearance.listener import OSThemeSwitchListener
|
||||
from pydantic_core import PydanticCustomError
|
||||
from qtpy.QtGui import QColor
|
||||
from qtpy.QtWidgets import QApplication, QPushButton, QToolButton
|
||||
from qtpy.QtWidgets import QApplication
|
||||
|
||||
|
||||
def get_theme_palette():
|
||||
if QApplication.instance() is None or not hasattr(QApplication.instance(), "theme"):
|
||||
theme = "dark"
|
||||
else:
|
||||
theme = QApplication.instance().theme["theme"]
|
||||
theme = QApplication.instance().theme.theme
|
||||
return bec_qthemes.load_palette(theme)
|
||||
|
||||
|
||||
@ -25,8 +25,8 @@ def _theme_update_callback():
|
||||
"""
|
||||
app = QApplication.instance()
|
||||
# pylint: disable=protected-access
|
||||
app.theme["theme"] = app.os_listener._theme.lower()
|
||||
app.theme_signal.theme_updated.emit(app.theme["theme"])
|
||||
app.theme.theme = app.os_listener._theme.lower()
|
||||
app.theme_signal.theme_updated.emit(app.theme.theme)
|
||||
apply_theme(app.os_listener._theme.lower())
|
||||
|
||||
|
||||
@ -124,7 +124,7 @@ class Colors:
|
||||
color_index = int(color_selection[ii])
|
||||
color = cmap_colors[color_index]
|
||||
app = QApplication.instance()
|
||||
if hasattr(app, "theme") and app.theme["theme"] == "light":
|
||||
if hasattr(app, "theme") and app.theme.theme == "light":
|
||||
background = 255
|
||||
else:
|
||||
background = 0
|
||||
|
@ -60,7 +60,7 @@ class DarkModeButton(BECWidget, QWidget):
|
||||
bool: True if dark mode is enabled, False otherwise.
|
||||
"""
|
||||
qapp = QApplication.instance()
|
||||
if hasattr(qapp, "theme") and qapp.theme["theme"] == "dark":
|
||||
if hasattr(qapp, "theme") and qapp.theme.theme == "dark":
|
||||
return True
|
||||
|
||||
return False
|
||||
|
@ -119,7 +119,7 @@ class BECPlotBase(BECConnector, pg.GraphicsLayout):
|
||||
if theme is None:
|
||||
qapp = QApplication.instance()
|
||||
if hasattr(qapp, "theme"):
|
||||
theme = qapp.theme["theme"]
|
||||
theme = qapp.theme.theme
|
||||
else:
|
||||
theme = "dark"
|
||||
self.apply_theme(theme)
|
||||
|
Reference in New Issue
Block a user