1717import warnings
1818from typing import Literal
1919
20- from guidata import qthelpers
20+ from guidata import qthelpers as qth
2121from guidata .configtools import add_image_module_path , get_translation
2222from guidata .userconfig import UserConfig
2323
24- IS_DARK = qthelpers .is_dark_mode ()
25-
2624
2725def get_main_colors () -> tuple [str , str ]:
2826 """Return main foreground and background colors depending on dark mode"""
29- global IS_DARK
30- return "white" if IS_DARK else "black" , "#222222" if IS_DARK else "white"
27+ is_dark = qth . is_dark_theme ()
28+ return "white" if is_dark else "black" , "#222222" if is_dark else "white"
3129
3230
3331MAIN_FG_COLOR , MAIN_BG_COLOR = get_main_colors ()
@@ -45,7 +43,7 @@ def make_title(basename, count):
4543
4644def get_plotpy_defaults () -> dict [str , int | float | str | bool ]:
4745 """Return default configuration values"""
48- global IS_DARK , MAIN_FG_COLOR , MAIN_BG_COLOR
46+ global MAIN_FG_COLOR , MAIN_BG_COLOR
4947 return {
5048 "plot" : {
5149 "selection/distance" : 6 ,
@@ -101,7 +99,7 @@ def get_plotpy_defaults() -> dict[str, int | float | str | bool]:
10199 "grid/maj_line/style" : "DotLine" ,
102100 "grid/min_xenabled" : True ,
103101 "grid/min_yenabled" : True ,
104- "grid/min_line/color" : "#454545" if IS_DARK else "#eaeaea" ,
102+ "grid/min_line/color" : "#454545" if qth . is_dark_theme () else "#eaeaea" ,
105103 "grid/min_line/width" : 1 ,
106104 "grid/min_line/style" : "DotLine" ,
107105 "marker/curve/symbol/marker" : "Rect" ,
@@ -304,7 +302,7 @@ def get_plotpy_defaults() -> dict[str, int | float | str | bool]:
304302 "shape/imagefilter/sel_symbol/edgecolor" : "#0000ff" ,
305303 "shape/imagefilter/sel_symbol/facecolor" : "#00ffff" ,
306304 "shape/imagefilter/sel_symbol/alpha" : 0.8 ,
307- # Contour ----------------------------------------------------------------------
305+ # Contour ------------------------------------------------------------------
308306 "shape/contour/line/style" : "SolidLine" ,
309307 "shape/contour/line/color" : "#000000" ,
310308 "shape/contour/line/width" : 1 ,
@@ -317,7 +315,7 @@ def get_plotpy_defaults() -> dict[str, int | float | str | bool]:
317315 "shape/contour/sel_fill/color" : MAIN_BG_COLOR ,
318316 "shape/contour/sel_fill/alpha" : 0.1 ,
319317 "shape/contour/sel_symbol/marker" : "NoSymbol" ,
320- # RectZoom ---------------------------------------------------------------------
318+ # RectZoom -----------------------------------------------------------------
321319 "shape/rectzoom/line/style" : "SolidLine" ,
322320 "shape/rectzoom/line/color" : "#bbbbbb" ,
323321 "shape/rectzoom/line/width" : 2 ,
@@ -772,8 +770,7 @@ def get_plotpy_defaults() -> dict[str, int | float | str | bool]:
772770
773771def update_plotpy_defaults () -> None :
774772 """Update the defaults with the current configuration"""
775- global DEFAULTS , IS_DARK , MAIN_BG_COLOR , MAIN_FG_COLOR
776- IS_DARK = qthelpers .is_dark_mode ()
773+ global DEFAULTS , MAIN_BG_COLOR , MAIN_FG_COLOR
777774 MAIN_FG_COLOR , MAIN_BG_COLOR = get_main_colors ()
778775 DEFAULTS = get_plotpy_defaults ()
779776 CONF .update_defaults (DEFAULTS )
@@ -808,7 +805,7 @@ def set_plotpy_dark_mode(state: bool) -> None:
808805 f"version. Use `set_plotpy_color_mode('{ mode } ')` instead." ,
809806 DeprecationWarning ,
810807 )
811- qthelpers .set_dark_mode (state ) # guidata 3.6.0
808+ qth .set_dark_mode (state ) # guidata 3.6.0
812809 update_plotpy_color_mode ()
813810
814811
@@ -819,5 +816,5 @@ def set_plotpy_color_mode(mode: Literal["light", "dark", "auto"] | None = None):
819816 mode: Color mode ('light', 'dark' or 'auto'). If 'auto', the system color mode
820817 is used. If None, the `QT_COLOR_MODE` environment variable is used.
821818 """
822- qthelpers .set_color_mode (mode ) # guidata >= 3.6.1
819+ qth .set_color_mode (mode ) # guidata >= 3.6.1
823820 update_plotpy_color_mode ()
0 commit comments