[add] folder structure automatically recognized when adding events
This commit is contained in:
parent
be463c2adf
commit
0a6ad8b663
44
QtPyLoT.py
44
QtPyLoT.py
@ -362,10 +362,10 @@ class MainWindow(QMainWindow):
|
|||||||
QCoreApplication.instance().quit,
|
QCoreApplication.instance().quit,
|
||||||
QKeySequence.Close, quitIcon,
|
QKeySequence.Close, quitIcon,
|
||||||
"Close event and quit PyLoT")
|
"Close event and quit PyLoT")
|
||||||
self.parameterAction = self.createAction(self, "Pick Parameter",
|
self.parameterAction = self.createAction(self, "Parameter",
|
||||||
self.pickParameter,
|
self.setParameter,
|
||||||
None, QIcon(None),
|
None, QIcon(None),
|
||||||
"Modify Picking Parameter")
|
"Modify Parameter")
|
||||||
self.filterAction = self.createAction(self, "&Filter ...",
|
self.filterAction = self.createAction(self, "&Filter ...",
|
||||||
self.filterWaveformData,
|
self.filterWaveformData,
|
||||||
"Ctrl+F", filter_icon,
|
"Ctrl+F", filter_icon,
|
||||||
@ -764,11 +764,46 @@ class MainWindow(QMainWindow):
|
|||||||
eventlist = [item for item in eventlist if item.split('/')[-1].startswith('e')
|
eventlist = [item for item in eventlist if item.split('/')[-1].startswith('e')
|
||||||
and len(item.split('/')[-1].split('.')) == 3
|
and len(item.split('/')[-1].split('.')) == 3
|
||||||
and len(item.split('/')[-1]) == 12]
|
and len(item.split('/')[-1]) == 12]
|
||||||
|
if not eventlist:
|
||||||
|
print('No events found! Expected structure for event folders: [evID.DOY.YR]')
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
if not self.project:
|
if not self.project:
|
||||||
print('No project found.')
|
print('No project found.')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
#get path from first event in list and split them
|
||||||
|
path = eventlist[0]
|
||||||
|
try:
|
||||||
|
dirs = {
|
||||||
|
'database': path.split('/')[-2],
|
||||||
|
'datapath': path.split('/')[-3],
|
||||||
|
'rootpath': os.path.join(*path.split('/')[:-3])
|
||||||
|
}
|
||||||
|
except Exception as e:
|
||||||
|
dirs = {
|
||||||
|
'database': ''
|
||||||
|
'datapath': ''
|
||||||
|
'rootpath': ''
|
||||||
|
}
|
||||||
|
print('Warning: Could not automatically init folder structure. ({})'.format(e))
|
||||||
|
|
||||||
|
if not self.project.eventlist:
|
||||||
|
#init parameter object
|
||||||
|
self.setParameter(show=False)
|
||||||
|
#hide all parameter (show all needed parameter later)
|
||||||
|
self.paraBox.hide_parameter()
|
||||||
|
for directory in dirs.keys():
|
||||||
|
#set parameter
|
||||||
|
box = self.paraBox.boxes[directory]
|
||||||
|
self.paraBox.setValue(box, dirs[directory])
|
||||||
|
#show needed parameter in box
|
||||||
|
self.paraBox.show_parameter(directory)
|
||||||
|
dirs_box = self.paraBox.get_groupbox_exclusive('Directories')
|
||||||
|
if not dirs_box.exec_():
|
||||||
|
return
|
||||||
|
|
||||||
self.project.add_eventlist(eventlist)
|
self.project.add_eventlist(eventlist)
|
||||||
self.init_events()
|
self.init_events()
|
||||||
self.setDirty(True)
|
self.setDirty(True)
|
||||||
@ -2273,11 +2308,12 @@ class MainWindow(QMainWindow):
|
|||||||
# self.closing.emit()
|
# self.closing.emit()
|
||||||
# QMainWindow.closeEvent(self, event)
|
# QMainWindow.closeEvent(self, event)
|
||||||
|
|
||||||
def pickParameter(self):
|
def setParameter(self, show=True):
|
||||||
if not self.paraBox:
|
if not self.paraBox:
|
||||||
self.paraBox = AutoPickParaBox(self._inputs)
|
self.paraBox = AutoPickParaBox(self._inputs)
|
||||||
self.paraBox._apply.clicked.connect(self._setDirty)
|
self.paraBox._apply.clicked.connect(self._setDirty)
|
||||||
self.paraBox._okay.clicked.connect(self._setDirty)
|
self.paraBox._okay.clicked.connect(self._setDirty)
|
||||||
|
if show:
|
||||||
self.paraBox.show()
|
self.paraBox.show()
|
||||||
|
|
||||||
def PyLoTprefs(self):
|
def PyLoTprefs(self):
|
||||||
|
@ -1 +1 @@
|
|||||||
ab97-dirty
|
be46-dirty
|
||||||
|
@ -2152,16 +2152,21 @@ class AutoPickParaBox(QtGui.QWidget):
|
|||||||
layout.insertWidget(position, groupbox)
|
layout.insertWidget(position, groupbox)
|
||||||
|
|
||||||
def get_groupbox_exclusive(self, name):
|
def get_groupbox_exclusive(self, name):
|
||||||
widget = QtGui.QWidget(self, 1)
|
dialog = QtGui.QDialog(self.parent())
|
||||||
self._exclusive_widget = widget
|
buttonbox = QtGui.QDialogButtonBox(QDialogButtonBox.Ok |
|
||||||
|
QDialogButtonBox.Cancel)
|
||||||
|
self._exclusive_dialog = dialog
|
||||||
layout = QtGui.QVBoxLayout()
|
layout = QtGui.QVBoxLayout()
|
||||||
button = QtGui.QPushButton('Okay')
|
dialog.setLayout(layout)
|
||||||
widget.setLayout(layout)
|
|
||||||
layout.addWidget(self.groupboxes[name])
|
layout.addWidget(self.groupboxes[name])
|
||||||
layout.addWidget(button)
|
layout.addWidget(buttonbox)
|
||||||
button.clicked.connect(widget.close)
|
buttonbox.accepted.connect(dialog.accept)
|
||||||
button.clicked.connect(self.refresh)
|
buttonbox.accepted.connect(self.refresh)
|
||||||
return widget
|
buttonbox.accepted.connect(self.params_from_gui)
|
||||||
|
buttonbox.rejected.connect(dialog.reject)
|
||||||
|
buttonbox.rejected.connect(self.refresh)
|
||||||
|
buttonbox.rejected.connect(self.params_to_gui)
|
||||||
|
return dialog
|
||||||
|
|
||||||
def add_to_layout(self, layout, name, items, position):
|
def add_to_layout(self, layout, name, items, position):
|
||||||
groupbox = QtGui.QGroupBox(name)
|
groupbox = QtGui.QGroupBox(name)
|
||||||
@ -2319,8 +2324,8 @@ class AutoPickParaBox(QtGui.QWidget):
|
|||||||
def show(self):
|
def show(self):
|
||||||
self.refresh()
|
self.refresh()
|
||||||
self.show_parameter()
|
self.show_parameter()
|
||||||
if hasattr(self, '_exclusive_widget'):
|
if hasattr(self, '_exclusive_dialog'):
|
||||||
self._exclusive_widget.close()
|
self._exclusive_dialog.close()
|
||||||
QtGui.QWidget.show(self)
|
QtGui.QWidget.show(self)
|
||||||
|
|
||||||
def _warn(self, message):
|
def _warn(self, message):
|
||||||
|
Loading…
Reference in New Issue
Block a user