14
14
from __future__ import annotations
15
15
16
16
import os .path as osp
17
+ import warnings
18
+ from typing import Literal
17
19
18
20
from guidata import qthelpers
19
21
from guidata .configtools import add_image_module_path , get_translation
@@ -777,13 +779,8 @@ def update_plotpy_defaults() -> None:
777
779
CONF .update_defaults (DEFAULTS )
778
780
779
781
780
- def set_plotpy_dark_mode (state : bool ) -> None :
781
- """Set dark mode for Qt application
782
-
783
- Args:
784
- state (bool): True to enable dark mode
785
- """
786
- qthelpers .set_dark_mode (state )
782
+ def update_plotpy_color_mode () -> None :
783
+ """Update the color mode for Plotpy"""
787
784
update_plotpy_defaults ()
788
785
789
786
# Iterate over all `BasePlot` widgets by browsing the QApplication:
@@ -797,3 +794,30 @@ def set_plotpy_dark_mode(state: bool) -> None:
797
794
for widget in app .topLevelWidgets ():
798
795
for child in widget .findChildren (BasePlot ):
799
796
child .update_color_mode ()
797
+
798
+
799
+ def set_plotpy_dark_mode (state : bool ) -> None :
800
+ """Set dark mode for Qt application
801
+
802
+ Args:
803
+ state (bool): True to enable dark mode
804
+ """
805
+ mode = "dark" if state else "light"
806
+ warnings .warn (
807
+ f"`set_plotpy_dark_mode` is deprecated and will be removed in a future "
808
+ f"version. Use `set_plotpy_color_mode('{ mode } ')` instead." ,
809
+ DeprecationWarning ,
810
+ )
811
+ qthelpers .set_dark_mode (state ) # guidata 3.6.0
812
+ update_plotpy_color_mode ()
813
+
814
+
815
+ def set_plotpy_color_mode (mode : Literal ["light" , "dark" , "auto" ] | None = None ):
816
+ """Set the color mode for Plotpy
817
+
818
+ Args:
819
+ mode: Color mode ('light', 'dark' or 'auto'). If 'auto', the system color mode
820
+ is used. If None, the `QT_COLOR_MODE` environment variable is used.
821
+ """
822
+ qthelpers .set_color_mode (mode ) # guidata >= 3.6.1
823
+ update_plotpy_color_mode ()
0 commit comments