добавлен класс окна настроек
This commit is contained in:
parent
d158aa449c
commit
eeaf15ff42
@ -1,4 +1,4 @@
|
||||
from OptAlgorithm.AutoConfigClass import AutoConfigClass
|
||||
from src.OptAlgorithm.AutoConfigClass import AutoConfigClass
|
||||
from numpy import sqrt
|
||||
|
||||
class ConstantCalculator(AutoConfigClass):
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
from OptAlgorithm.PhaseCalc import PhaseCalc
|
||||
from OptAlgorithm.OptTimeCalculator import OptTimeCalculator
|
||||
from OptAlgorithm.AutoConfigClass import AutoConfigClass
|
||||
from OptAlgorithm.ConstantCalculator import ConstantCalculator
|
||||
from src.OptAlgorithm.PhaseCalc import PhaseCalc
|
||||
from src.OptAlgorithm.OptTimeCalculator import OptTimeCalculator
|
||||
from src.OptAlgorithm.AutoConfigClass import AutoConfigClass
|
||||
from src.OptAlgorithm.ConstantCalculator import ConstantCalculator
|
||||
|
||||
from numpy import cos, sin, sqrt, cbrt, arcsin
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
from numpy import sqrt, arcsin, arccos, cos, sin
|
||||
|
||||
from OptAlgorithm.AutoConfigClass import AutoConfigClass
|
||||
from OptAlgorithm.ConstantCalculator import ConstantCalculator
|
||||
from src.OptAlgorithm.AutoConfigClass import AutoConfigClass
|
||||
from src.OptAlgorithm.ConstantCalculator import ConstantCalculator
|
||||
|
||||
class OptTimeCalculator(AutoConfigClass):
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
1
src/__init__.py
Normal file
1
src/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
||||
BIN
src/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
src/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
@ -1 +1,2 @@
|
||||
from .plot_window import PlotWindow
|
||||
from .settings_windows import settingsWindow
|
||||
|
||||
Binary file not shown.
Binary file not shown.
BIN
src/gui/__pycache__/settings_windows.cpython-310.pyc
Normal file
BIN
src/gui/__pycache__/settings_windows.cpython-310.pyc
Normal file
Binary file not shown.
@ -1,8 +1,8 @@
|
||||
import pyqtgraph as pg
|
||||
import numpy as np
|
||||
|
||||
from gui import qt_settings as qts
|
||||
from OptAlgorithm import OptAlgorithm
|
||||
from src.gui import qt_settings as qts
|
||||
from src.OptAlgorithm import OptAlgorithm
|
||||
|
||||
|
||||
class PlotWindow:
|
||||
|
||||
64
src/gui/settings_windows.py
Normal file
64
src/gui/settings_windows.py
Normal file
@ -0,0 +1,64 @@
|
||||
import pyqtgraph as pg
|
||||
from pyqtgraph.Qt import QtWidgets
|
||||
import pyqtgraph.parametertree.parameterTypes as pTypes
|
||||
from pyqtgraph.parametertree import Parameter, ParameterTree
|
||||
|
||||
from src.utils.json_tools import read_json, write_json
|
||||
|
||||
class settingsWindow(QtWidgets.QWidget):
|
||||
def __init__(self, path: str, name: str):
|
||||
super(settingsWindow, self).__init__()
|
||||
self.settingsPath = path
|
||||
self.name = name
|
||||
|
||||
self.data = {}
|
||||
self.params = None
|
||||
self.load_settings()
|
||||
self.init_ui()
|
||||
|
||||
def load_settings(self):
|
||||
self.data = read_json(self.settingsPath)
|
||||
|
||||
def write_settings(self):
|
||||
write_json(self.settingsPath, self.data)
|
||||
|
||||
def _getTreeStructure(self) -> list:
|
||||
params = []
|
||||
for key, value in self.data.items():
|
||||
params.append({'name': str(key), 'type': type(value).__name__, 'value': value})
|
||||
return params
|
||||
|
||||
def init_ui(self):
|
||||
temp = self._getTreeStructure()
|
||||
self.params = Parameter.create(name='params', type='group', children=temp)
|
||||
self.params.sigTreeStateChanged.connect(self.change)
|
||||
|
||||
ParamsTree = ParameterTree()
|
||||
ParamsTree.setParameters(self.params)
|
||||
ParamsTree.setWindowTitle('Settings ,f,f')
|
||||
layout = QtWidgets.QGridLayout()
|
||||
layout.addWidget(ParamsTree, 0,0)
|
||||
self.setLayout(layout)
|
||||
|
||||
self.show()
|
||||
|
||||
def change(self, param, changes):
|
||||
print("tree changes:")
|
||||
for param, change, data in changes:
|
||||
path = self.params.childPath(param)
|
||||
if path is not None:
|
||||
childName = '.'.join(path)
|
||||
else:
|
||||
childName = param.name()
|
||||
print(' parameter: %s'% childName)
|
||||
print(' change: %s'% change)
|
||||
print(' data: %s'% str(data))
|
||||
print(' ----------')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = pg.mkQApp("Parameter Tree Example")
|
||||
window = settingsWindow('params\operator_params.json', 'operator')
|
||||
app.exec()
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
from uml.request_generator import Request
|
||||
from src.uml.request_generator import Request
|
||||
|
||||
|
||||
class UMLCreator:
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
from .json_tools import read_json
|
||||
from .json_tools import read_json, write_json
|
||||
from .diagram_parser import DiagramParser
|
||||
Binary file not shown.
Binary file not shown.
@ -9,3 +9,13 @@ def read_json(filepath: str) -> dict:
|
||||
with open(filepath, 'r') as json_file:
|
||||
data = json.load(json_file)
|
||||
return data
|
||||
|
||||
def write_json(filepath: str, data: dict):
|
||||
if not path.exists(filepath):
|
||||
raise FileNotFoundError(f"JSON file {filepath} not found!")
|
||||
|
||||
try:
|
||||
with open(filepath, 'w') as json_file:
|
||||
json.dump(data, json_file)
|
||||
except Exception as e:
|
||||
raise e
|
||||
Loading…
Reference in New Issue
Block a user