17
17
import warnings
18
18
from typing import Literal
19
19
20
- from guidata import qthelpers
20
+ from guidata import qthelpers as qth
21
21
from guidata .configtools import add_image_module_path , get_translation
22
22
from guidata .userconfig import UserConfig
23
23
24
- IS_DARK = qthelpers .is_dark_mode ()
25
-
26
24
27
25
def get_main_colors () -> tuple [str , str ]:
28
26
"""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"
31
29
32
30
33
31
MAIN_FG_COLOR , MAIN_BG_COLOR = get_main_colors ()
@@ -45,7 +43,7 @@ def make_title(basename, count):
45
43
46
44
def get_plotpy_defaults () -> dict [str , int | float | str | bool ]:
47
45
"""Return default configuration values"""
48
- global IS_DARK , MAIN_FG_COLOR , MAIN_BG_COLOR
46
+ global MAIN_FG_COLOR , MAIN_BG_COLOR
49
47
return {
50
48
"plot" : {
51
49
"selection/distance" : 6 ,
@@ -101,7 +99,7 @@ def get_plotpy_defaults() -> dict[str, int | float | str | bool]:
101
99
"grid/maj_line/style" : "DotLine" ,
102
100
"grid/min_xenabled" : True ,
103
101
"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" ,
105
103
"grid/min_line/width" : 1 ,
106
104
"grid/min_line/style" : "DotLine" ,
107
105
"marker/curve/symbol/marker" : "Rect" ,
@@ -304,7 +302,7 @@ def get_plotpy_defaults() -> dict[str, int | float | str | bool]:
304
302
"shape/imagefilter/sel_symbol/edgecolor" : "#0000ff" ,
305
303
"shape/imagefilter/sel_symbol/facecolor" : "#00ffff" ,
306
304
"shape/imagefilter/sel_symbol/alpha" : 0.8 ,
307
- # Contour ----------------------------------------------------------------------
305
+ # Contour ------------------------------------------------------------------
308
306
"shape/contour/line/style" : "SolidLine" ,
309
307
"shape/contour/line/color" : "#000000" ,
310
308
"shape/contour/line/width" : 1 ,
@@ -317,7 +315,7 @@ def get_plotpy_defaults() -> dict[str, int | float | str | bool]:
317
315
"shape/contour/sel_fill/color" : MAIN_BG_COLOR ,
318
316
"shape/contour/sel_fill/alpha" : 0.1 ,
319
317
"shape/contour/sel_symbol/marker" : "NoSymbol" ,
320
- # RectZoom ---------------------------------------------------------------------
318
+ # RectZoom -----------------------------------------------------------------
321
319
"shape/rectzoom/line/style" : "SolidLine" ,
322
320
"shape/rectzoom/line/color" : "#bbbbbb" ,
323
321
"shape/rectzoom/line/width" : 2 ,
@@ -772,8 +770,7 @@ def get_plotpy_defaults() -> dict[str, int | float | str | bool]:
772
770
773
771
def update_plotpy_defaults () -> None :
774
772
"""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
777
774
MAIN_FG_COLOR , MAIN_BG_COLOR = get_main_colors ()
778
775
DEFAULTS = get_plotpy_defaults ()
779
776
CONF .update_defaults (DEFAULTS )
@@ -808,7 +805,7 @@ def set_plotpy_dark_mode(state: bool) -> None:
808
805
f"version. Use `set_plotpy_color_mode('{ mode } ')` instead." ,
809
806
DeprecationWarning ,
810
807
)
811
- qthelpers .set_dark_mode (state ) # guidata 3.6.0
808
+ qth .set_dark_mode (state ) # guidata 3.6.0
812
809
update_plotpy_color_mode ()
813
810
814
811
@@ -819,5 +816,5 @@ def set_plotpy_color_mode(mode: Literal["light", "dark", "auto"] | None = None):
819
816
mode: Color mode ('light', 'dark' or 'auto'). If 'auto', the system color mode
820
817
is used. If None, the `QT_COLOR_MODE` environment variable is used.
821
818
"""
822
- qthelpers .set_color_mode (mode ) # guidata >= 3.6.1
819
+ qth .set_color_mode (mode ) # guidata >= 3.6.1
823
820
update_plotpy_color_mode ()
0 commit comments