feat: добавил конфиг
This commit is contained in:
parent
5e430fad6e
commit
78fa10d897
4
config/config.json
Normal file
4
config/config.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"trace_storage_path": "/home/andrei/Desktop/bla",
|
||||
"monitor_update_period": 100
|
||||
}
|
||||
6
src/cfg/schema.py
Normal file
6
src/cfg/schema.py
Normal file
@ -0,0 +1,6 @@
|
||||
from typing import NamedTuple
|
||||
|
||||
|
||||
class ConfigSchema(NamedTuple):
|
||||
trace_storage_path: str
|
||||
monitor_update_period: int
|
||||
14
src/main.py
14
src/main.py
@ -1,10 +1,24 @@
|
||||
import sys
|
||||
from PyQt5 import QtWidgets
|
||||
import json
|
||||
from os import path
|
||||
|
||||
from gui.mainGui import MainWindow
|
||||
from cfg.schema import ConfigSchema
|
||||
|
||||
|
||||
def read_json(filepath: str) -> dict:
|
||||
if not path.exists(filepath):
|
||||
raise FileNotFoundError(f"JSON file {filepath} not found!")
|
||||
|
||||
with open(filepath, 'r') as json_file:
|
||||
content = json.load(json_file)
|
||||
return content
|
||||
|
||||
|
||||
def main():
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
config = ConfigSchema(**read_json("config/config.json"))
|
||||
|
||||
window = MainWindow()
|
||||
window.show()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user