Skip to content

Commit

Permalink
major project restructure to enable easier containerization
Browse files Browse the repository at this point in the history
  • Loading branch information
cjtitus committed Dec 19, 2023
1 parent 9557c80 commit a327f72
Show file tree
Hide file tree
Showing 34 changed files with 106 additions and 35 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml → src/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors = [
{ email = "[email protected]" },
]
requires-python = ">=3.7"
dependencies = ["bluesky_widgets", "qtpy"]
dependencies = ["bluesky_widgets", "qtpy", "ucal", "sst_base", "sst_funcs"]

[project.urls]
homepage = "https://github.com/NSLS-II-SST/sst-gui" # Replace with your project's homepage
Expand Down
2 changes: 1 addition & 1 deletion setup.py → src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
author="[email protected]",
python_requires=">=3.7",
description="SST1 GUI",
install_requires=["bluesky_widgets", "qtpy"],
install_requires=["bluesky_widgets", "qtpy", "ucal", "sst_base", "sst_funcs"],
packages=find_packages(),
name="sst_gui",
use_scm_version=True,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion sst_gui/loaders.py → src/sst_gui/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
ControlModel,
PVPositionerModel,
)
import pkg_resources

SST_CONFIG = "/home/jamie/work/nsls-ii-sst/ucal/ucal/sim_config.yaml"
SST_CONFIG = pkg_resources.resource_filename("ucal", "sim_config.yaml")


def modelFromOphyd(prefix, group=None, label=None, modelClass=BaseModel, **kwargs):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
102 changes: 102 additions & 0 deletions src/sst_gui/widgets/samplelist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
from qtpy.QtWidgets import (
QTableView,
QWidget,
QVBoxLayout,
QPushButton,
QFileDialog,
QLabel,
)
from qtpy.QtCore import QAbstractTableModel, Qt, Signal, Slot
from bluesky_queueserver_api import BFunc


class SampleTab(QWidget):
def __init__(self, model, parent=None):
super().__init__(parent)
self.layout = QVBoxLayout(self)
self.model = model

self.file_picker = FilePicker(model.run_engine, parent=self)
self.layout.addWidget(self.file_picker)
# Widget 2: QtSampleView
self.sample_view = QtSampleView(model.user_status, parent=self)
self.layout.addWidget(self.sample_view)


class FilePicker(QWidget):
def __init__(self, run_engine_client, parent=None):
# Widget 1: File picker
super().__init__(parent)
self.run_engine_client = run_engine_client
self.layout = QVBoxLayout(self)
self.file_picker = QPushButton("Pick a file", self)
self.file_picker.clicked.connect(self.pick_file)
self.layout.addWidget(self.file_picker)
self.selected_file = None

def pick_file(self):
fname = QFileDialog.getOpenFileName(self, "Open file")
if fname[0]:
self.selected_file = fname[0]
item = BFunc("load_standard_four_sided_bar", self.selected_file)
self.run_engine_client._client.function_execute(item=item)


class QtSampleView(QTableView):
signal_update_widget = Signal(object)

def __init__(self, model, parent=None):
super().__init__(parent)
self.model = model
self.signal_update_widget.connect(self.update_md)
self.model.register_signal("SAMPLE_LIST", self.signal_update_widget)
self.tableModel = DictTableModel({})
self.setModel(self.tableModel)

@Slot(object)
def update_md(self, samples):
self.tableModel.update(samples)


class DictTableModel(QAbstractTableModel):
def __init__(self, data):
super().__init__()
self._data = data

def data(self, index, role):
if role == Qt.DisplayRole:
key = list(self._data.keys())[index.row()]
key2 = list(self._data[key].keys())[index.column()]
return str(self._data[key][key2])

def rowCount(self, index):
return len(self._data.keys())

def columnCount(self, index):
mincol = None
for k, v in self._data.items():
if mincol is None:
mincol = len(v.keys())
else:
mincol = min(len(v.keys()), mincol)
if mincol is None:
return 0
else:
return mincol

def update(self, new_data):
self.beginResetModel()
self._data = new_data
self._rows = list(self._data.keys())
if len(self._rows) > 0:
for k, v in self._data.items():
self._columns = list(v.keys())
break
self.endResetModel()

def headerData(self, section, orientation, role):
if role == Qt.DisplayRole:
if orientation == Qt.Horizontal:
return str(self._columns[section])
if orientation == Qt.Vertical:
return self._rows[section]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
32 changes: 0 additions & 32 deletions widgets.py

This file was deleted.

0 comments on commit a327f72

Please sign in to comment.