Skip to content

Commit

Permalink
style: detect if OS is dark mode and automatically set that
Browse files Browse the repository at this point in the history
  • Loading branch information
ElpadoCan committed Jun 19, 2023
1 parent 013751c commit 874f267
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions cellacdc/__init__.py
Expand Up @@ -95,6 +95,29 @@
'Type "y" for "yes", or "n" for "no".'
)

temp_path = os.path.join(cellacdc_path, 'temp')
settings_csv_path = os.path.join(temp_path, 'settings.csv')
if not os.path.exists(temp_path):
os.makedirs(temp_path)
if not os.path.exists(settings_csv_path):
import pandas as pd
df_settings = pd.DataFrame(
{'setting': [], 'value': []}).set_index('setting')
df_settings.to_csv(settings_csv_path)

# Check OS dark or light mode
from qtpy.QtWidgets import QApplication, QStyleFactory
from qtpy.QtGui import QPalette
app = QApplication([])
app.setStyle(QStyleFactory.create('Fusion'))
is_OS_dark_mode = app.palette().color(QPalette.Window).getHsl()[2] < 100
if is_OS_dark_mode:
import pandas as pd
df_settings = pd.read_csv(settings_csv_path, index_col='setting')
if 'colorScheme' not in df_settings.index:
df_settings.at['colorScheme', 'value'] = 'dark'
df_settings.to_csv(settings_csv_path)

import sys
import os
import inspect
Expand Down Expand Up @@ -158,10 +181,8 @@ def printl(*objects, pretty=False, is_decorator=False, **kwargs):
parent_path = os.path.dirname(cellacdc_path)
html_path = os.path.join(cellacdc_path, '_html')
data_path = os.path.join(parent_path, 'data')
temp_path = os.path.join(cellacdc_path, 'temp')
resources_folderpath = os.path.join(cellacdc_path, 'resources')
resources_filepath = os.path.join(cellacdc_path, 'resources.qrc')
settings_csv_path = os.path.join(temp_path, 'settings.csv')
logs_path = os.path.join(user_path, '.acdc-logs')
resources_path = os.path.join(cellacdc_path, 'resources.qrc')
models_list_file_path = os.path.join(temp_path, 'custom_models_paths.ini')
Expand All @@ -172,9 +193,6 @@ def printl(*objects, pretty=False, is_decorator=False, **kwargs):
# `m = re.sub(segm_re_pattern, '_acdc_output', segm_filename)`
segm_re_pattern = r'_segm(?!.*_segm)'

if not os.path.exists(temp_path):
os.makedirs(temp_path)

try:
from setuptools_scm import get_version
__version__ = get_version(root='..', relative_to=__file__)
Expand Down

0 comments on commit 874f267

Please sign in to comment.