store font size in settings file

This commit is contained in:
2021-10-29 09:21:46 +02:00
parent 74e89ff78b
commit bc8f9b006d
6 changed files with 93 additions and 30 deletions

36
settingsstore.py Normal file
View File

@@ -0,0 +1,36 @@
import os
from typing import Callable
from settings import Settings
from pathlib import Path
from os.path import join, isfile
from configparser import ConfigParser
class SettingsStore():
def __init__(self):
pass
@staticmethod
def _config_file() -> str:
return join(Path.home(), ".ravenlog", "settings.ini")
@staticmethod
def load() -> Settings:
config_file = SettingsStore._config_file()
config = ConfigParser()
# apply default settings
config.add_section('general')
config.set('general', 'font_size', '12')
config.read(config_file)
return Settings(config)
@staticmethod
def save(settings: Settings):
config_file = SettingsStore._config_file()
dir = os.path.dirname(config_file)
os.makedirs(dir, exist_ok=True)
with open(config_file, 'w+') as fp:
settings.config.write(fp)