diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -1,3 +1,4 @@ __pycache__/ ^\.idea/ ^images/ +^config.json$ diff --git a/config.json.template b/config.json.template new file mode 100644 --- /dev/null +++ b/config.json.template @@ -0,0 +1,9 @@ +{ + "misc": { + "defaultImage": "1.jpg" + }, + "gui": { + "showGrid": true, + "showBigPoints": false + } +} diff --git a/src/config.py b/src/config.py --- a/src/config.py +++ b/src/config.py @@ -1,11 +1,18 @@ +import os import logging +import json logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=logging.DEBUG) +with open(os.path.join(os.path.dirname(__file__), "..", "config.json")) as f: + cfgFile=json.load(f) class misc: + file=cfgFile["misc"] version=(0,0,0) + defaultImage=file.get("defaultImage", "1.jpg") class gui: - showBigPoints=True - showGrid=False + file=cfgFile["gui"] + showBigPoints=file.get("showBigPoints", False) + showGrid=file.get("showGrid", True) diff --git a/src/core.py b/src/core.py --- a/src/core.py +++ b/src/core.py @@ -7,6 +7,7 @@ from util import MsgQueue from gui import gui from imageanalyzer import ImageAnalyzer from go import Go +import config as cfg class Core: @@ -18,7 +19,7 @@ class Core: self._ownMessages=MsgQueue(self._handleEvent) self._guiMessages=MsgQueue() - imgPath=os.path.join(os.path.dirname(__file__), "..","images","5.jpg") + imgPath=os.path.join(os.path.dirname(__file__), "..","images",cfg.misc.defaultImage) self._frame=PIL.Image.open(imgPath) self._guiProc=multiprocessing.Process(name="gui", target=gui, args=(self._guiMessages,self._ownMessages))