Files
photobooth/photobooth/Config.py
Balthasar Reuter ade6d05aee Initial commit for the more modular rewrite of the Photobooth.
Basic Qt5-GUI implemented
Config-File support implemented
Basic settings dialog to change config implemented
NO Photobooth functionality, yet
2018-03-17 14:54:08 +01:00

69 lines
1.1 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import configparser, os
class Config:
def __init__(self, filename):
self._filename = filename
self._cfg = configparser.ConfigParser()
self.defaults()
self.read()
@property
def filename(self):
return self._filename
@filename.setter
def filename(self, value):
self._filename = value
def defaults(self):
self._cfg.read(os.path.join(os.path.dirname(__file__), 'defaults.cfg'))
def read(self):
self._cfg.read(self._filename)
def write(self):
with open(self._filename, 'w') as configfile:
self._cfg.write(configfile)
def get(self, section, key):
return self._cfg[section][key]
def getInt(self, section, key):
return self._cfg.getint(section, key)
def getFloat(self, section, key):
return self._cfg.getfloat(section, key)
def getBool(self, section, key):
return self._cfg.getboolean(section, key)
def set(self, section, key, value):
self._cfg[section][key] = value