Changeset - f85a79f2fd95
[Not reviewed]
default
0 3 1
Laman - 8 years ago 2017-02-28 20:18:20

added JSON config file
4 files changed with 21 insertions and 3 deletions:
0 comments (0 inline, 0 general)
.hgignore
Show inline comments
 
__pycache__/
 
^\.idea/
 
^images/
 
^config.json$
config.json.template
Show inline comments
 
new file 100644
 
{
 
	"misc": {
 
		"defaultImage": "1.jpg"
 
	},
 
	"gui": {
 
		"showGrid": true,
 
		"showBigPoints": false
 
	}
 
}
src/config.py
Show inline comments
 
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)
src/core.py
Show inline comments
 
@@ -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))
0 comments (0 inline, 0 general)