optimize imports and cleanup code

This commit is contained in:
2024-09-25 12:36:48 +02:00
parent 457ea0e675
commit 3fc4f50c15
16 changed files with 37 additions and 4994 deletions

View File

@@ -13,54 +13,17 @@ This contains a Widget to handle FixTargetFrames and fiducials, calculate final
#https://stackoverflow.com/questions/27909658/json-encoder-and-decoder-for-complex-numpy-arrays
# import yaml
# class Dice(tuple):
# def __new__(cls, a, b):
# return tuple.__new__(cls, [a, b])
# def __repr__(self):
# return "Dice(%s,%s)" % self
# d=Dice(3,6)
# print(d)
# print(yaml.dump(d))
# def dice_representer(dumper, data):
# return dumper.represent_scalar(u'!dice', u'%sd%s' % data)
# yaml.add_representer(Dice, dice_representer)
# def dice_constructor(loader, node):
# value = loader.construct_scalar(node)
# a, b = map(int, value.split('d'))
# return Dice(a, b)
# yaml.add_constructor(u'!dice', dice_constructor)
# print(yaml.load("initial hit points: !dice 8d4"))
import logging
_log=logging.getLogger(__name__)
import json, base64 #, os, pickle, yaml
import json, base64
import numpy as np
import pyqtUsrObj as UsrGO
import pyqtgraph as pg
from PyQt5.QtCore import Qt, QFileInfo, pyqtSignal, pyqtSlot
from PyQt5.QtCore import Qt, QFileInfo, pyqtSignal
from PyQt5.QtWidgets import (
QTableWidgetItem,
QFileDialog,
QGroupBox,
QWidget,
QGridLayout,
QTableWidget,
QAbstractItemView,
QItemDelegate,
QVBoxLayout,
QLabel,
QPushButton,
QApplication,
QMainWindow,
QHeaderView,
QLineEdit,
QSpinBox,
QMessageBox,
QAction,
QComboBox,
QCheckBox)
QFileDialog, QWidget, QGridLayout, QItemDelegate, QVBoxLayout, QPushButton, QApplication,
QMainWindow, QLineEdit, QMessageBox, QAction, QComboBox)
class MyJsonEncoder(json.JSONEncoder):
@@ -109,8 +72,6 @@ class MarkerDelegate(QItemDelegate):
return comboBox
def setEditorData(self, editor, index):
# pos = comboBox.findText(index.model().data(index), Qt.MatchExactly)
# comboBox.setCurrentIndex(pos)
editor.setText("{}".format(index.model().data(index)))
def setModelData(self, editor, model, index):
@@ -158,27 +119,11 @@ class WndFixTarget(QWidget):
btnSv.clicked.connect(lambda: self.save_file())
bl.addWidget(btnSv, 0, 1)
# but = QPushButton("Random Data")
# but.clicked.connect(self.generate_random_data)
# bl.addWidget(but, 4, 0)
# self._num_random_points = QSpinBox()
# self._num_random_points.setMinimum(2)
# self._num_random_points.setMaximum(10000)
# self._num_random_points.setValue(10)
# self._num_random_points.setSuffix(" points")
# bl.addWidget(self._num_random_points, 4, 1)
btnDump = QPushButton("dump")
btnDump.clicked.connect(self.dump_data)
bl.addWidget(btnDump, 0, 2)
self._cbType=cb=QComboBox()
#cb.addItem("C")
#cb.addItem("C++")
#cb.addItems(["Fiducial", "FixTarget(12.5x12.5)", "FixTarget(23.0x23.0)", "FixTarget(<param>)", "Grid(<param>)"])
#cb.currentIndexChanged.connect(self.selectionchange)
bl.addWidget(cb, 1,0,1,1)
self._txtParam=param=QLineEdit()
@@ -196,23 +141,7 @@ class WndFixTarget(QWidget):
bl.addWidget(btnFit, 2, 1,1,1)
layout.addWidget(frame)
#self.markersTable.itemSelectionChanged.connect(self.selection_changed)
#self.markersTable.setContextMenuPolicy(Qt.ActionsContextMenu)
#deleteRowAction = QAction("Delete this row", self)
#deleteRowAction.triggered.connect(self.delete_selected)
#self.markersTable.addAction(deleteRowAction)
#moveRequestAction = QAction("Move Here", self)
#moveRequestAction.triggered.connect(self.request_stage_movement)
#self.markersTable.addAction(moveRequestAction)
#layout.addWidget(self.markersTable, stretch=2)
#self.connect_all_signals()
#self._yamlFn=fn=os.path.expanduser('~/.config/PSI/SwissMX.yaml')
#self._tree=tree=pg.DataTreeWidget(data=self._data)
self._data=data
self._tree=tree=pg.DataTreeWidget(data=data)
layout.addWidget(tree, stretch=2)