-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.py
84 lines (63 loc) · 2.15 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import time
import threading
import configparser
from themes import *
class SingletonType(type):
_instance_lock = threading.Lock()
def __call__(cls, *args, **kwargs):
if not hasattr(cls, "_instance"):
with SingletonType._instance_lock:
if not hasattr(cls, "_instance"):
cls._instance = super(SingletonType,cls).__call__(*args, **kwargs)
return cls._instance
class Config(metaclass=SingletonType):
def __init__(self):
self.__config = configparser.ConfigParser()
self.__config_file = "config.ini"
self.__config.read(self.__config_file)
if self.__config.has_option('win', 'win_pos_x'):
self._win_pos_x = int(self.__config.get('win', 'win_pos_x'))
else:
self._win_pos_x = None
if self.__config.has_option('win', 'win_pos_y'):
self._win_pos_y = int(self.__config.get('win', 'win_pos_y'))
else:
self._win_pos_y = None
self._win_width = 1280
self._win_height = 400
self._show_cursor = int(self.__config.get('win', 'show_cursor')) == 1
self._theme_name = self.__config.get('win', 'theme_name')
#self._fps = 60
self._fps = 30
@property
def win_pos_x(self):
return self._win_pos_x
@property
def win_pos_y(self):
return self._win_pos_y
@property
def win_width(self):
return self._win_width
@property
def win_height(self):
return self._win_height
@property
def fps(self):
return self._fps
@property
def show_cursor(self):
return self._show_cursor
def save_config_file(self):
self.__config.write(open(self.__config_file, "w"))
@property
def background_color(self):
return themes[self._theme_name]['background_color']
@property
def active_background_color(self):
return themes[self._theme_name]['active_background_color']
@property
def text_color(self):
return themes[self._theme_name]['text_color']
@property
def highlight_text_color(self):
return themes[self._theme_name]['highlight_text_color']