rework settings, add pyqtUsrObj.py
This commit is contained in:
@@ -8,14 +8,22 @@
|
||||
import logging
|
||||
_log = logging.getLogger(__name__)
|
||||
|
||||
import os
|
||||
from PyQt5.QtCore import QSettings
|
||||
#import yaml
|
||||
#from pathlib import Path
|
||||
import os, json, yaml
|
||||
|
||||
class AppCfg(QSettings):
|
||||
WINDOW_GEOMETRY="window/geometry"
|
||||
WINDOW_STATE= "window/state"
|
||||
WINDOW_SPLITTER="window/splitter"
|
||||
|
||||
# ---------- OBSOLETE ??? ----------
|
||||
ZOOM_BUTTONS="sample_viewing/zoom_buttons"
|
||||
|
||||
SKIP_ESCAPE_TRANSITIONS_IF_SAFE="escape/skip_transitions_if_safe"
|
||||
|
||||
GEO_OPT_CTR='geometry/opt_ctr'
|
||||
GEO_PIX2POS='geometry/pix2pos'
|
||||
|
||||
BEAM_MARKER_POSITIONS="beam/marker_positions"
|
||||
BEAM_SIZE="beam/size"
|
||||
|
||||
@@ -39,31 +47,37 @@ class AppCfg(QSettings):
|
||||
def __init__(self):
|
||||
super(AppCfg, self).__init__("PSI", "SwissMX")
|
||||
keys = self.allKeys()
|
||||
if AppCfg.ACTIVATE_PULSE_PICKER not in keys:
|
||||
self.setValue(AppCfg.ACTIVATE_PULSE_PICKER, False)
|
||||
#set default keys if not existing
|
||||
if AppCfg.BEAM_SIZE not in keys:
|
||||
self.setValue(AppCfg.BEAM_SIZE, [40, 20]) #([40, 20) -> tuples are not supported natively
|
||||
|
||||
if AppCfg.SKIP_ESCAPE_TRANSITIONS_IF_SAFE not in keys:
|
||||
self.setValue(AppCfg.SKIP_ESCAPE_TRANSITIONS_IF_SAFE, False)
|
||||
#if AppCfg.ACTIVATE_PULSE_PICKER not in keys:
|
||||
# self.setValue(AppCfg.ACTIVATE_PULSE_PICKER, False)
|
||||
|
||||
if "hits/marker_size" not in keys:
|
||||
self.setValue("hits/marker_size", 10)
|
||||
#if AppCfg.SKIP_ESCAPE_TRANSITIONS_IF_SAFE not in keys:
|
||||
# self.setValue(AppCfg.SKIP_ESCAPE_TRANSITIONS_IF_SAFE, False)
|
||||
|
||||
if "graphs/show_auxiliary" not in keys:
|
||||
self.setValue("graphs/show_auxiliary", False)
|
||||
def sync(self):
|
||||
super(AppCfg, self).sync()
|
||||
#import numpy as np
|
||||
#a=np.array(((1,2,3),(4,5,6)))
|
||||
#self._yamlFn=fn=os.path.expanduser('~/.config/PSI/SwissMX.yaml')
|
||||
#_yaml = [{'name': 'John Doe', 'occupation': 'gardener'},
|
||||
# {'name': 'Lucy Black', 'occupation': 'teacher'}]
|
||||
#_yaml = {'name': 'John Doe', 'occupation': 'gardener','A':(1,2,3),'B':{1,2,3},'C': {1:(1,2,3),2:'df',3:'dddd'},4:a }
|
||||
#with open(self._yamlFn, 'w') as f:
|
||||
# data = yaml.dump(_yaml, f)
|
||||
# print(data)
|
||||
|
||||
if "graphs/auxiliary_graph_index" not in keys:
|
||||
self.setValue("graphs/auxiliary_graph_index", 0)
|
||||
|
||||
if "scan_request/last_location" not in keys:
|
||||
d10 = os.path.join(os.path.expanduser("~"), "Data10")
|
||||
self.setValue("scan_request/last_location", d10)
|
||||
|
||||
if AppCfg.BEAM_SIZE in keys:
|
||||
_log.info("setting beamsize from stored settings: {}".format(self.value(AppCfg.BEAM_SIZE)))
|
||||
else:
|
||||
_log.warning("beam size may not reflect reality, please check")
|
||||
self.setValue(AppCfg.BEAM_SIZE, (40, 20))
|
||||
def setValue(self, key: str, val): #overload to debug
|
||||
return super(AppCfg, self).setValue(key,val)
|
||||
|
||||
def value(self,key,*vargs): #overload to debug
|
||||
val=super(AppCfg, self).value(key,*vargs)
|
||||
return val
|
||||
#@property
|
||||
#def value(self):
|
||||
# return super(AppCfg, self).value
|
||||
|
||||
def option(self,key: str) -> bool:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user