Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d3ee217bc5 | |||
| 7fe986ae4e | |||
| 43e582271e | |||
| 39f717ea6b |
15
enumkind.py
15
enumkind.py
@@ -4,6 +4,8 @@ from enum import IntEnum
|
|||||||
class ElogSwissFEL:
|
class ElogSwissFEL:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.category = self.Category(0)
|
self.category = self.Category(0)
|
||||||
|
self.category_data = self.CategoryData(0)
|
||||||
|
self.category_test = self.CategoryTest(0)
|
||||||
self.domain = self.Domain(0)
|
self.domain = self.Domain(0)
|
||||||
self.system = self.System(0)
|
self.system = self.System(0)
|
||||||
|
|
||||||
@@ -23,6 +25,19 @@ class ElogSwissFEL:
|
|||||||
RC = 12
|
RC = 12
|
||||||
WEEKLY_REF = 13
|
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):
|
class Domain(IntEnum):
|
||||||
NONE = 0
|
NONE = 0
|
||||||
GLOBAL = 1
|
GLOBAL = 1
|
||||||
|
|||||||
@@ -38,7 +38,9 @@ class QSendToELOG(QSendToELOGFrame):
|
|||||||
|
|
||||||
super().__init__(parent, logbook=logbook, title=title, message=message)
|
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?
|
#First check what is the logbook being requested?
|
||||||
#find layout items
|
#find layout items
|
||||||
self.layout_items = self.get_logbook_specific_items(self.logbook)
|
self.layout_items = self.get_logbook_specific_items(self.logbook)
|
||||||
@@ -73,6 +75,7 @@ class QSendToELOG(QSendToELOGFrame):
|
|||||||
self.sim_list = ["Sand", "test"]
|
self.sim_list = ["Sand", "test"]
|
||||||
|
|
||||||
self.initialize_layout(self.logbook)
|
self.initialize_layout(self.logbook)
|
||||||
|
|
||||||
self.exec()
|
self.exec()
|
||||||
|
|
||||||
def reset_layout(self):
|
def reset_layout(self):
|
||||||
@@ -83,22 +86,14 @@ class QSendToELOG(QSendToELOGFrame):
|
|||||||
widget = item.widget()
|
widget = item.widget()
|
||||||
widget.deleteLater()
|
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):
|
for layout in self.get_logbook_specific_items(self.logbook):
|
||||||
print(layout, "layout", flush=True)
|
|
||||||
remove_wgt(self.layout_to_widget_dict[layout])
|
remove_wgt(self.layout_to_widget_dict[layout])
|
||||||
print(layout, "layout-removed", flush=True)
|
|
||||||
|
|
||||||
|
|
||||||
def create_layout_widgets(self):
|
def create_layout_widgets(self):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if not self.eintrag:
|
if not self.eintrag:
|
||||||
print("EINTRAG", flush=True)
|
|
||||||
self.eintrag = QHBoxLayout()
|
self.eintrag = QHBoxLayout()
|
||||||
self.eintrag.addWidget(QLabel('Eintrag: '))
|
self.eintrag.addWidget(QLabel('Eintrag: '))
|
||||||
self.eintrag_items = QComboBox()
|
self.eintrag_items = QComboBox()
|
||||||
@@ -107,7 +102,6 @@ class QSendToELOG(QSendToELOGFrame):
|
|||||||
self.layout_to_widget_dict['Eintrag'] = self.eintrag
|
self.layout_to_widget_dict['Eintrag'] = self.eintrag
|
||||||
|
|
||||||
if not self.category:
|
if not self.category:
|
||||||
print("CATEGORY", flush=True)
|
|
||||||
self.category = QHBoxLayout()
|
self.category = QHBoxLayout()
|
||||||
self.category.addWidget(QLabel('Category: '))
|
self.category.addWidget(QLabel('Category: '))
|
||||||
self.category_items = QComboBox()
|
self.category_items = QComboBox()
|
||||||
@@ -116,7 +110,6 @@ class QSendToELOG(QSendToELOGFrame):
|
|||||||
self.layout_to_widget_dict['Category'] = self.category
|
self.layout_to_widget_dict['Category'] = self.category
|
||||||
|
|
||||||
if not self.domain:
|
if not self.domain:
|
||||||
print("DOMAIN", flush=True)
|
|
||||||
self.domain = QHBoxLayout()
|
self.domain = QHBoxLayout()
|
||||||
self.domain.addWidget(QLabel('Domain: '))
|
self.domain.addWidget(QLabel('Domain: '))
|
||||||
self.domain_items = QComboBox()
|
self.domain_items = QComboBox()
|
||||||
@@ -126,7 +119,6 @@ class QSendToELOG(QSendToELOGFrame):
|
|||||||
self.layout_to_widget_dict['Domain'] = self.domain
|
self.layout_to_widget_dict['Domain'] = self.domain
|
||||||
|
|
||||||
if not self.system:
|
if not self.system:
|
||||||
print("SYSTEM", flush=True)
|
|
||||||
self.system = QHBoxLayout()
|
self.system = QHBoxLayout()
|
||||||
self.system.addWidget(QLabel('System: '))
|
self.system.addWidget(QLabel('System: '))
|
||||||
self.system_items = QComboBox()
|
self.system_items = QComboBox()
|
||||||
@@ -136,7 +128,6 @@ class QSendToELOG(QSendToELOGFrame):
|
|||||||
|
|
||||||
|
|
||||||
if not self.section:
|
if not self.section:
|
||||||
print("SECTION", flush=True)
|
|
||||||
self.section = QHBoxLayout()
|
self.section = QHBoxLayout()
|
||||||
self.section.addWidget(QLabel('Section: '))
|
self.section.addWidget(QLabel('Section: '))
|
||||||
self.section_items = QComboBox()
|
self.section_items = QComboBox()
|
||||||
@@ -146,7 +137,6 @@ class QSendToELOG(QSendToELOGFrame):
|
|||||||
|
|
||||||
|
|
||||||
if not self.effekt:
|
if not self.effekt:
|
||||||
print("EFFEKT", flush=True)
|
|
||||||
self.effekt = QHBoxLayout()
|
self.effekt = QHBoxLayout()
|
||||||
self.effekt.addWidget(QLabel('Effect: '))
|
self.effekt.addWidget(QLabel('Effect: '))
|
||||||
self.effekt_le = QLineEdit()
|
self.effekt_le = QLineEdit()
|
||||||
@@ -158,7 +148,6 @@ class QSendToELOG(QSendToELOGFrame):
|
|||||||
self.layout_to_widget_dict['Effect'] = self.effekt
|
self.layout_to_widget_dict['Effect'] = self.effekt
|
||||||
|
|
||||||
if not self.estatus:
|
if not self.estatus:
|
||||||
print("STATUS", flush=True)
|
|
||||||
self.estatus = QHBoxLayout()
|
self.estatus = QHBoxLayout()
|
||||||
self.estatus.addWidget(QLabel('Status: '))
|
self.estatus.addWidget(QLabel('Status: '))
|
||||||
self.estatus_items = QComboBox()
|
self.estatus_items = QComboBox()
|
||||||
@@ -166,18 +155,22 @@ class QSendToELOG(QSendToELOGFrame):
|
|||||||
self.estatus.addWidget(self.estatus_items)
|
self.estatus.addWidget(self.estatus_items)
|
||||||
self.layout_to_widget_dict['Status'] = self.estatus
|
self.layout_to_widget_dict['Status'] = self.estatus
|
||||||
|
|
||||||
print("END", flush=True)
|
|
||||||
|
|
||||||
def initialize_layout(self, logbook):
|
def initialize_layout(self, logbook):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#Decide on layout
|
#Decide on layout
|
||||||
self.create_layout_widgets()
|
self.create_layout_widgets()
|
||||||
|
|
||||||
|
|
||||||
item_no = 2
|
item_no = 2
|
||||||
|
|
||||||
print("HERE===========00>", logbook, flush=True)
|
|
||||||
|
|
||||||
if 'Eintrag' in self.layout_items:
|
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.clear()
|
||||||
self.eintrag_items.addItems(list(self.parent.settings.data[
|
self.eintrag_items.addItems(list(self.parent.settings.data[
|
||||||
'ElogBooks'][logbook]['Required']['Eintrag']))
|
'ElogBooks'][logbook]['Required']['Eintrag']))
|
||||||
@@ -185,9 +178,13 @@ class QSendToELOG(QSendToELOGFrame):
|
|||||||
self.layout.insertLayout(item_no, self.eintrag)
|
self.layout.insertLayout(item_no, self.eintrag)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if 'Category' in self.layout_items:
|
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()
|
self.category_items.clear()
|
||||||
key = 'Required' if 'Required' in self.parent.settings.data[
|
key = 'Required' if 'Required' in self.parent.settings.data[
|
||||||
"ElogBooks"][logbook] else 'Optional'
|
"ElogBooks"][logbook] else 'Optional'
|
||||||
@@ -199,12 +196,10 @@ class QSendToELOG(QSendToELOGFrame):
|
|||||||
|
|
||||||
if 'Effect' in self.layout_items:
|
if 'Effect' in self.layout_items:
|
||||||
item_no += 1
|
item_no += 1
|
||||||
print("Effect", item_no, flush=True)
|
|
||||||
self.layout.insertLayout(item_no, self.effekt)
|
self.layout.insertLayout(item_no, self.effekt)
|
||||||
|
|
||||||
if 'Domain' in self.layout_items:
|
if 'Domain' in self.layout_items:
|
||||||
item_no += 1
|
item_no += 1
|
||||||
print("Domain", item_no, flush=True)
|
|
||||||
self.domain_items.clear()
|
self.domain_items.clear()
|
||||||
self.domain_items.addItems(list(self.parent.settings.data[
|
self.domain_items.addItems(list(self.parent.settings.data[
|
||||||
'ElogBooks'][logbook]['Optional']['Domain']))
|
'ElogBooks'][logbook]['Optional']['Domain']))
|
||||||
@@ -213,7 +208,7 @@ class QSendToELOG(QSendToELOGFrame):
|
|||||||
|
|
||||||
if 'Section' in self.layout_items:
|
if 'Section' in self.layout_items:
|
||||||
item_no += 1
|
item_no += 1
|
||||||
print("Section", item_no, flush=True)
|
|
||||||
self.section_items.clear()
|
self.section_items.clear()
|
||||||
self.section_items.addItems(list(self.parent.settings.data[
|
self.section_items.addItems(list(self.parent.settings.data[
|
||||||
'ElogBooks'][logbook]['Optional']['Section'][self.domain_idx]))
|
'ElogBooks'][logbook]['Optional']['Section'][self.domain_idx]))
|
||||||
@@ -222,7 +217,8 @@ class QSendToELOG(QSendToELOGFrame):
|
|||||||
|
|
||||||
if 'System' in self.layout_items:
|
if 'System' in self.layout_items:
|
||||||
item_no += 1
|
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.clear()
|
||||||
self.system_items.addItems(list(self.parent.settings.data[
|
self.system_items.addItems(list(self.parent.settings.data[
|
||||||
'ElogBooks'][logbook]['Optional']['System']))
|
'ElogBooks'][logbook]['Optional']['System']))
|
||||||
@@ -231,23 +227,18 @@ class QSendToELOG(QSendToELOGFrame):
|
|||||||
|
|
||||||
if 'Status' in self.layout_items:
|
if 'Status' in self.layout_items:
|
||||||
item_no += 1
|
item_no += 1
|
||||||
print("Status", item_no, flush=True)
|
|
||||||
self.estatus_items.clear()
|
self.estatus_items.clear()
|
||||||
self.estatus_items.addItems(list(self.parent.settings.data[
|
self.estatus_items.addItems(list(self.parent.settings.data[
|
||||||
'ElogBooks'][logbook]['Optional']['Status']))
|
'ElogBooks'][logbook]['Optional']['Status']))
|
||||||
self.estatus_items.setCurrentIndex(self.status_idx)
|
self.estatus_items.setCurrentIndex(self.status_idx)
|
||||||
self.layout.insertLayout(item_no, self.estatus)
|
self.layout.insertLayout(item_no, self.estatus)
|
||||||
|
|
||||||
|
#IS this required --attached files should be passed on
|
||||||
|
|
||||||
|
|
||||||
print("self.attachFile==>", self.parent.attach_files)
|
|
||||||
|
|
||||||
|
|
||||||
self.attachFile = self.parent.attach_files
|
self.attachFile = self.parent.attach_files
|
||||||
self.filesE.clear()
|
self.filesE.clear()
|
||||||
self.files_text = ''
|
self.files_text = ''
|
||||||
|
|
||||||
|
|
||||||
if self.attachFile is not None:
|
if self.attachFile is not None:
|
||||||
_attachFile = []
|
_attachFile = []
|
||||||
if isinstance(self.attachFile, str):
|
if isinstance(self.attachFile, str):
|
||||||
@@ -269,18 +260,20 @@ class QSendToELOG(QSendToELOGFrame):
|
|||||||
_bgcolor = "QComboBox {background: lightblue; color : black;}"
|
_bgcolor = "QComboBox {background: lightblue; color : black;}"
|
||||||
self.elog_items.setStyleSheet(_bgcolor)
|
self.elog_items.setStyleSheet(_bgcolor)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#have to remove widgets within layout too!
|
#have to remove widgets within layout too!
|
||||||
#https://riverbankcomputing.com/pipermail/pyqt/2009-November/025214.html
|
#https://riverbankcomputing.com/pipermail/pyqt/2009-November/025214.html
|
||||||
def on_elog_change(self, idx):
|
def on_elog_change(self, idx):
|
||||||
|
|
||||||
print(self.elog_items.currentText(), "new=", idx)
|
#print(self.elog_items.currentText(), "new=", idx)
|
||||||
print(self.elog_items.itemText(idx))
|
#print(self.elog_items.itemText(idx))
|
||||||
print(self.logbook)
|
#print(self.logbook)
|
||||||
|
|
||||||
new_logbook = self.elog_items.itemText(idx)
|
new_logbook = self.elog_items.itemText(idx)
|
||||||
|
|
||||||
print("NEW", new_logbook, flush=True)
|
#print("NEW", new_logbook, flush=True)
|
||||||
print("OLD", self.logbook, flush=True)
|
#print("OLD", self.logbook, flush=True)
|
||||||
|
|
||||||
#Meet the new logbook. Same as the old logbook
|
#Meet the new logbook. Same as the old logbook
|
||||||
if new_logbook == self.logbook:
|
if new_logbook == self.logbook:
|
||||||
@@ -292,9 +285,8 @@ class QSendToELOG(QSendToELOGFrame):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
print("self.layout_items START", self.layout_items, flush=True)
|
|
||||||
self.layout_items = self.get_logbook_specific_items(new_logbook)
|
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() \
|
if any(substring.upper() in new_logbook.upper() \
|
||||||
@@ -311,6 +303,7 @@ class QSendToELOG(QSendToELOGFrame):
|
|||||||
def on_domain_change(self, i):
|
def on_domain_change(self, i):
|
||||||
self.section_items.clear()
|
self.section_items.clear()
|
||||||
self.section_items.addItems(self.elog_section[i])
|
self.section_items.addItems(self.elog_section[i])
|
||||||
|
#self.section_items.setCurrentIndex(0)
|
||||||
|
|
||||||
def ok(self):
|
def ok(self):
|
||||||
#proj = self.category_items.currentText()
|
#proj = self.category_items.currentText()
|
||||||
|
|||||||
Reference in New Issue
Block a user