Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b67a601228 | |||
| d3ee217bc5 | |||
| 7fe986ae4e | |||
| 43e582271e | |||
| 39f717ea6b |
15
enumkind.py
15
enumkind.py
@@ -4,6 +4,8 @@ from enum import IntEnum
|
||||
class ElogSwissFEL:
|
||||
def __init__(self):
|
||||
self.category = self.Category(0)
|
||||
self.category_data = self.CategoryData(0)
|
||||
self.category_test = self.CategoryTest(0)
|
||||
self.domain = self.Domain(0)
|
||||
self.system = self.System(0)
|
||||
|
||||
@@ -22,6 +24,19 @@ class ElogSwissFEL:
|
||||
SCHICHT_AUFTRAG = 11
|
||||
RC = 12
|
||||
WEEKLY_REF = 13
|
||||
|
||||
class CategoryData(IntEnum):
|
||||
INFO = 0
|
||||
MEASUREMENT = 1
|
||||
|
||||
class CategoryTest(IntEnum):
|
||||
SHIFT_SUMMARY = 0
|
||||
MEASUREMENT = 1
|
||||
PROCEDURES = 2
|
||||
PROBLEM = 3
|
||||
INFO = 4
|
||||
UBERBRUCKUNG = 5
|
||||
PRE_BEAM_CHECK = 6
|
||||
|
||||
class Domain(IntEnum):
|
||||
NONE = 0
|
||||
|
||||
@@ -5,8 +5,8 @@ import random
|
||||
|
||||
from qtpy.QtCore import Qt, QTimer
|
||||
from qtpy.QtGui import QFont
|
||||
from qtpy.QtWidgets import (QApplication, QGridLayout, QGroupBox, QHBoxLayout,
|
||||
QLabel, QRadioButton, QWidget)
|
||||
from qtpy.QtWidgets import (QApplication, QGridLayout, QGroupBox,
|
||||
QHBoxLayout, QLabel, QRadioButton, QWidget)
|
||||
from caqtwidgets.pvwidgets import CAQLabel, QHLine, QVLine
|
||||
|
||||
from pyqtacc.bdbase.enumkind import UserMode
|
||||
@@ -153,7 +153,7 @@ class GUIHeader(QWidget):
|
||||
if reset:
|
||||
self.reset_beamline()
|
||||
self.target_beamline = target
|
||||
|
||||
|
||||
def reset_beamline(self):
|
||||
""" Reset QGroupBox for previous target to original colors
|
||||
"""
|
||||
|
||||
@@ -38,7 +38,9 @@ class QSendToELOG(QSendToELOGFrame):
|
||||
|
||||
super().__init__(parent, logbook=logbook, title=title, message=message)
|
||||
|
||||
#print ("ELOG SEND", flush=True)
|
||||
self.settings = self.parent.settings
|
||||
|
||||
|
||||
#First check what is the logbook being requested?
|
||||
#find layout items
|
||||
self.layout_items = self.get_logbook_specific_items(self.logbook)
|
||||
@@ -73,6 +75,7 @@ class QSendToELOG(QSendToELOGFrame):
|
||||
self.sim_list = ["Sand", "test"]
|
||||
|
||||
self.initialize_layout(self.logbook)
|
||||
|
||||
self.exec()
|
||||
|
||||
def reset_layout(self):
|
||||
@@ -83,22 +86,14 @@ class QSendToELOG(QSendToELOGFrame):
|
||||
widget = item.widget()
|
||||
widget.deleteLater()
|
||||
|
||||
print("old logbook==>", self.logbook)
|
||||
print("remove==>", self.get_logbook_specific_items(self.logbook),
|
||||
flush=True)
|
||||
|
||||
for layout in self.get_logbook_specific_items(self.logbook):
|
||||
print(layout, "layout", flush=True)
|
||||
remove_wgt(self.layout_to_widget_dict[layout])
|
||||
print(layout, "layout-removed", flush=True)
|
||||
|
||||
|
||||
def create_layout_widgets(self):
|
||||
|
||||
|
||||
|
||||
|
||||
if not self.eintrag:
|
||||
print("EINTRAG", flush=True)
|
||||
self.eintrag = QHBoxLayout()
|
||||
self.eintrag.addWidget(QLabel('Eintrag: '))
|
||||
self.eintrag_items = QComboBox()
|
||||
@@ -107,7 +102,6 @@ class QSendToELOG(QSendToELOGFrame):
|
||||
self.layout_to_widget_dict['Eintrag'] = self.eintrag
|
||||
|
||||
if not self.category:
|
||||
print("CATEGORY", flush=True)
|
||||
self.category = QHBoxLayout()
|
||||
self.category.addWidget(QLabel('Category: '))
|
||||
self.category_items = QComboBox()
|
||||
@@ -116,7 +110,6 @@ class QSendToELOG(QSendToELOGFrame):
|
||||
self.layout_to_widget_dict['Category'] = self.category
|
||||
|
||||
if not self.domain:
|
||||
print("DOMAIN", flush=True)
|
||||
self.domain = QHBoxLayout()
|
||||
self.domain.addWidget(QLabel('Domain: '))
|
||||
self.domain_items = QComboBox()
|
||||
@@ -126,7 +119,6 @@ class QSendToELOG(QSendToELOGFrame):
|
||||
self.layout_to_widget_dict['Domain'] = self.domain
|
||||
|
||||
if not self.system:
|
||||
print("SYSTEM", flush=True)
|
||||
self.system = QHBoxLayout()
|
||||
self.system.addWidget(QLabel('System: '))
|
||||
self.system_items = QComboBox()
|
||||
@@ -136,7 +128,6 @@ class QSendToELOG(QSendToELOGFrame):
|
||||
|
||||
|
||||
if not self.section:
|
||||
print("SECTION", flush=True)
|
||||
self.section = QHBoxLayout()
|
||||
self.section.addWidget(QLabel('Section: '))
|
||||
self.section_items = QComboBox()
|
||||
@@ -146,7 +137,6 @@ class QSendToELOG(QSendToELOGFrame):
|
||||
|
||||
|
||||
if not self.effekt:
|
||||
print("EFFEKT", flush=True)
|
||||
self.effekt = QHBoxLayout()
|
||||
self.effekt.addWidget(QLabel('Effect: '))
|
||||
self.effekt_le = QLineEdit()
|
||||
@@ -158,36 +148,43 @@ class QSendToELOG(QSendToELOGFrame):
|
||||
self.layout_to_widget_dict['Effect'] = self.effekt
|
||||
|
||||
if not self.estatus:
|
||||
print("STATUS", flush=True)
|
||||
self.estatus = QHBoxLayout()
|
||||
self.estatus.addWidget(QLabel('Status: '))
|
||||
self.estatus_items = QComboBox()
|
||||
self.estatus_items.setObjectName("Elog")
|
||||
self.estatus.addWidget(self.estatus_items)
|
||||
self.layout_to_widget_dict['Status'] = self.estatus
|
||||
|
||||
print("END", flush=True)
|
||||
|
||||
|
||||
|
||||
def initialize_layout(self, logbook):
|
||||
|
||||
|
||||
|
||||
#Decide on layout
|
||||
self.create_layout_widgets()
|
||||
|
||||
|
||||
item_no = 2
|
||||
|
||||
print("HERE===========00>", logbook, flush=True)
|
||||
|
||||
if 'Eintrag' in self.layout_items:
|
||||
print("EINTRAG", item_no, flush=True)
|
||||
self.eintrag_idx = self.settings.data['ElogInit'][logbook][
|
||||
'Eintrag']
|
||||
|
||||
self.eintrag_items.clear()
|
||||
self.eintrag_items.addItems(list(self.parent.settings.data[
|
||||
'ElogBooks'][logbook]['Required']['Eintrag']))
|
||||
self.eintrag_items.setCurrentIndex(self.eintrag_idx)
|
||||
self.layout.insertLayout(item_no, self.eintrag)
|
||||
|
||||
|
||||
|
||||
|
||||
if 'Category' in self.layout_items:
|
||||
print("Categ", item_no, flush=True)
|
||||
try:
|
||||
self.category_idx = self.settings.data['ElogInit'][logbook][
|
||||
'Category']
|
||||
except KeyError as ex:
|
||||
print("Did not find Category Index" + str(ex))
|
||||
|
||||
self.category_items.clear()
|
||||
key = 'Required' if 'Required' in self.parent.settings.data[
|
||||
"ElogBooks"][logbook] else 'Optional'
|
||||
@@ -199,21 +196,19 @@ class QSendToELOG(QSendToELOGFrame):
|
||||
|
||||
if 'Effect' in self.layout_items:
|
||||
item_no += 1
|
||||
print("Effect", item_no, flush=True)
|
||||
self.layout.insertLayout(item_no, self.effekt)
|
||||
|
||||
if 'Domain' in self.layout_items:
|
||||
item_no += 1
|
||||
print("Domain", item_no, flush=True)
|
||||
self.domain_items.clear()
|
||||
self.domain_items.addItems(list(self.parent.settings.data[
|
||||
'ElogBooks'][logbook]['Optional']['Domain']))
|
||||
self.domain_items.setCurrentIndex(self.domain_idx)
|
||||
self.layout.insertLayout(item_no, self.domain)
|
||||
|
||||
|
||||
if 'Section' in self.layout_items:
|
||||
item_no += 1
|
||||
print("Section", item_no, flush=True)
|
||||
|
||||
self.section_items.clear()
|
||||
self.section_items.addItems(list(self.parent.settings.data[
|
||||
'ElogBooks'][logbook]['Optional']['Section'][self.domain_idx]))
|
||||
@@ -222,7 +217,8 @@ class QSendToELOG(QSendToELOGFrame):
|
||||
|
||||
if 'System' in self.layout_items:
|
||||
item_no += 1
|
||||
print("System", item_no, flush=True)
|
||||
self.system_idx = self.settings.data['ElogInit'][logbook][
|
||||
'System']
|
||||
self.system_items.clear()
|
||||
self.system_items.addItems(list(self.parent.settings.data[
|
||||
'ElogBooks'][logbook]['Optional']['System']))
|
||||
@@ -231,22 +227,17 @@ class QSendToELOG(QSendToELOGFrame):
|
||||
|
||||
if 'Status' in self.layout_items:
|
||||
item_no += 1
|
||||
print("Status", item_no, flush=True)
|
||||
self.estatus_items.clear()
|
||||
self.estatus_items.addItems(list(self.parent.settings.data[
|
||||
'ElogBooks'][logbook]['Optional']['Status']))
|
||||
self.estatus_items.setCurrentIndex(self.status_idx)
|
||||
self.layout.insertLayout(item_no, self.estatus)
|
||||
|
||||
|
||||
|
||||
|
||||
print("self.attachFile==>", self.parent.attach_files)
|
||||
|
||||
|
||||
#IS this required --attached files should be passed on
|
||||
self.attachFile = self.parent.attach_files
|
||||
self.filesE.clear()
|
||||
self.files_text = ''
|
||||
|
||||
|
||||
if self.attachFile is not None:
|
||||
_attachFile = []
|
||||
@@ -261,7 +252,7 @@ class QSendToELOG(QSendToELOGFrame):
|
||||
self.files_text += str(_attach_base)
|
||||
self.filesE.setText(self.files_text)
|
||||
self.fflag = True
|
||||
|
||||
|
||||
if any(substring.upper() in logbook.upper() \
|
||||
for substring in self.sim_list):
|
||||
_bgcolor = "QComboBox {background: plum; color : black;}"
|
||||
@@ -269,18 +260,20 @@ class QSendToELOG(QSendToELOGFrame):
|
||||
_bgcolor = "QComboBox {background: lightblue; color : black;}"
|
||||
self.elog_items.setStyleSheet(_bgcolor)
|
||||
|
||||
|
||||
|
||||
#have to remove widgets within layout too!
|
||||
#https://riverbankcomputing.com/pipermail/pyqt/2009-November/025214.html
|
||||
def on_elog_change(self, idx):
|
||||
|
||||
print(self.elog_items.currentText(), "new=", idx)
|
||||
print(self.elog_items.itemText(idx))
|
||||
print(self.logbook)
|
||||
#print(self.elog_items.currentText(), "new=", idx)
|
||||
#print(self.elog_items.itemText(idx))
|
||||
#print(self.logbook)
|
||||
|
||||
new_logbook = self.elog_items.itemText(idx)
|
||||
|
||||
print("NEW", new_logbook, flush=True)
|
||||
print("OLD", self.logbook, flush=True)
|
||||
#print("NEW", new_logbook, flush=True)
|
||||
#print("OLD", self.logbook, flush=True)
|
||||
|
||||
#Meet the new logbook. Same as the old logbook
|
||||
if new_logbook == self.logbook:
|
||||
@@ -292,10 +285,9 @@ class QSendToELOG(QSendToELOGFrame):
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
print("self.layout_items START", self.layout_items, flush=True)
|
||||
|
||||
self.layout_items = self.get_logbook_specific_items(new_logbook)
|
||||
print("self.layout_items END", self.layout_items, flush=True)
|
||||
|
||||
|
||||
|
||||
if any(substring.upper() in new_logbook.upper() \
|
||||
for substring in self.sim_list):
|
||||
@@ -311,6 +303,7 @@ class QSendToELOG(QSendToELOGFrame):
|
||||
def on_domain_change(self, i):
|
||||
self.section_items.clear()
|
||||
self.section_items.addItems(self.elog_section[i])
|
||||
#self.section_items.setCurrentIndex(0)
|
||||
|
||||
def ok(self):
|
||||
#proj = self.category_items.currentText()
|
||||
|
||||
Reference in New Issue
Block a user