[add] folder structure automatically recognized when adding events
This commit is contained in:
parent
be463c2adf
commit
0a6ad8b663
46
QtPyLoT.py
46
QtPyLoT.py
@ -362,10 +362,10 @@ class MainWindow(QMainWindow):
|
||||
QCoreApplication.instance().quit,
|
||||
QKeySequence.Close, quitIcon,
|
||||
"Close event and quit PyLoT")
|
||||
self.parameterAction = self.createAction(self, "Pick Parameter",
|
||||
self.pickParameter,
|
||||
self.parameterAction = self.createAction(self, "Parameter",
|
||||
self.setParameter,
|
||||
None, QIcon(None),
|
||||
"Modify Picking Parameter")
|
||||
"Modify Parameter")
|
||||
self.filterAction = self.createAction(self, "&Filter ...",
|
||||
self.filterWaveformData,
|
||||
"Ctrl+F", filter_icon,
|
||||
@ -764,11 +764,46 @@ class MainWindow(QMainWindow):
|
||||
eventlist = [item for item in eventlist if item.split('/')[-1].startswith('e')
|
||||
and len(item.split('/')[-1].split('.')) == 3
|
||||
and len(item.split('/')[-1]) == 12]
|
||||
if not eventlist:
|
||||
print('No events found! Expected structure for event folders: [evID.DOY.YR]')
|
||||
return
|
||||
else:
|
||||
return
|
||||
if not self.project:
|
||||
print('No project found.')
|
||||
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.init_events()
|
||||
self.setDirty(True)
|
||||
@ -2273,12 +2308,13 @@ class MainWindow(QMainWindow):
|
||||
# self.closing.emit()
|
||||
# QMainWindow.closeEvent(self, event)
|
||||
|
||||
def pickParameter(self):
|
||||
def setParameter(self, show=True):
|
||||
if not self.paraBox:
|
||||
self.paraBox = AutoPickParaBox(self._inputs)
|
||||
self.paraBox._apply.clicked.connect(self._setDirty)
|
||||
self.paraBox._okay.clicked.connect(self._setDirty)
|
||||
self.paraBox.show()
|
||||
if show:
|
||||
self.paraBox.show()
|
||||
|
||||
def PyLoTprefs(self):
|
||||
if not self._props:
|
||||
|
@ -1 +1 @@
|
||||
ab97-dirty
|
||||
be46-dirty
|
||||
|
@ -2152,16 +2152,21 @@ class AutoPickParaBox(QtGui.QWidget):
|
||||
layout.insertWidget(position, groupbox)
|
||||
|
||||
def get_groupbox_exclusive(self, name):
|
||||
widget = QtGui.QWidget(self, 1)
|
||||
self._exclusive_widget = widget
|
||||
dialog = QtGui.QDialog(self.parent())
|
||||
buttonbox = QtGui.QDialogButtonBox(QDialogButtonBox.Ok |
|
||||
QDialogButtonBox.Cancel)
|
||||
self._exclusive_dialog = dialog
|
||||
layout = QtGui.QVBoxLayout()
|
||||
button = QtGui.QPushButton('Okay')
|
||||
widget.setLayout(layout)
|
||||
dialog.setLayout(layout)
|
||||
layout.addWidget(self.groupboxes[name])
|
||||
layout.addWidget(button)
|
||||
button.clicked.connect(widget.close)
|
||||
button.clicked.connect(self.refresh)
|
||||
return widget
|
||||
layout.addWidget(buttonbox)
|
||||
buttonbox.accepted.connect(dialog.accept)
|
||||
buttonbox.accepted.connect(self.refresh)
|
||||
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):
|
||||
groupbox = QtGui.QGroupBox(name)
|
||||
@ -2319,8 +2324,8 @@ class AutoPickParaBox(QtGui.QWidget):
|
||||
def show(self):
|
||||
self.refresh()
|
||||
self.show_parameter()
|
||||
if hasattr(self, '_exclusive_widget'):
|
||||
self._exclusive_widget.close()
|
||||
if hasattr(self, '_exclusive_dialog'):
|
||||
self._exclusive_dialog.close()
|
||||
QtGui.QWidget.show(self)
|
||||
|
||||
def _warn(self, message):
|
||||
|
Loading…
Reference in New Issue
Block a user