GUI: + config file & choosing a metric mode

This commit is contained in:
Wiktor Mazur
2019-09-19 20:04:31 +02:00
parent 28e2886a13
commit fbd57745ed
7 changed files with 136 additions and 24 deletions
+35
View File
@@ -0,0 +1,35 @@
import os
import toml
CFG_VERSION = '0.1'
default = """
[window]
width = 300
height = 200
font-size = '10px'
opacity = 0.5
[config]
# do not change
version = '%s'
""" % (CFG_VERSION)
def config():
conf_file = os.path.join(os.path.dirname(
os.path.realpath(__file__)), 'albion-online-stats.cfg')
try:
with open(conf_file, "r") as cfg_file:
cfg = toml.load(cfg_file)
if cfg['config']['version'] != CFG_VERSION:
print('version changed')
raise Exception('Version changed')
return cfg
except(Exception) as e:
with open(conf_file, "w") as cfg_file:
cfg_file.write(default)
return toml.loads(default)
return {}