[change] major changes in AutoPickParaBox layout, now structured as groupboxes that can be hidden individually

This commit is contained in:
Marcel Paffrath 2017-06-07 10:30:15 +02:00
parent 0af795969b
commit 66c5142cb9
2 changed files with 84 additions and 29 deletions

View File

@ -1 +1 @@
f7d0-dirty 0af79-dirty

View File

@ -1767,7 +1767,9 @@ class AutoPickParaBox(QtGui.QWidget):
self._init_save_buttons() self._init_save_buttons()
self._init_tabs() self._init_tabs()
self._init_dialog_buttons() self._init_dialog_buttons()
self.labels = {}
self.boxes = {} self.boxes = {}
self.groupboxes = {}
self._init_sublayouts() self._init_sublayouts()
self.setLayout(self.layout) self.setLayout(self.layout)
self.add_main_parameters_tab() self.add_main_parameters_tab()
@ -1834,12 +1836,10 @@ class AutoPickParaBox(QtGui.QWidget):
b.setEnabled(enable) b.setEnabled(enable)
def set_tune_mode(self, bool): def set_tune_mode(self, bool):
keys = ['rootpath', 'datapath', 'database', names = ['Directories', 'NLLoc',
'eventID', 'invdir', 'nllocbin', 'Seismic Moment']
'nllocroot', 'phasefile', for name in names:
'ctrfile', 'ttpatter', 'outpatter'] self.hide_groupbox(name)
for key in keys:
self.boxes[key].setEnabled(not(bool))
if bool: if bool:
self._apply.hide() self._apply.hide()
self._okay.hide() self._okay.hide()
@ -1870,6 +1870,7 @@ class AutoPickParaBox(QtGui.QWidget):
boxes.append(self.create_box(typ, tooltip)) boxes.append(self.create_box(typ, tooltip))
box = self.create_multi_box(boxes) box = self.create_multi_box(boxes)
self.boxes[name] = boxes self.boxes[name] = boxes
self.labels[name] = label
label.setToolTip(tooltip) label.setToolTip(tooltip)
grid.addWidget(label, index1, 1) grid.addWidget(label, index1, 1)
grid.addWidget(box, index1, 2) grid.addWidget(box, index1, 2)
@ -1892,7 +1893,7 @@ class AutoPickParaBox(QtGui.QWidget):
def create_multi_box(self, boxes): def create_multi_box(self, boxes):
box = QtGui.QWidget() box = QtGui.QWidget()
hl = QtGui.QHBoxLayout() hl = QtGui.QVBoxLayout()
for b in boxes: for b in boxes:
hl.addWidget(b) hl.addWidget(b)
box.setLayout(hl) box.setLayout(hl)
@ -1916,8 +1917,7 @@ class AutoPickParaBox(QtGui.QWidget):
self.add_to_layout(self._main_layout, 'Seismic Moment', self.add_to_layout(self._main_layout, 'Seismic Moment',
self.parameter.get_main_para_names()['smoment']) self.parameter.get_main_para_names()['smoment'])
self.add_to_layout(self._main_layout, 'Common Settings Characteristic Function', self.add_to_layout(self._main_layout, 'Common Settings Characteristic Function',
self.parameter.get_main_para_names()['pick'], self.parameter.get_main_para_names()['pick'])
False)
self.add_tab(self._main_layout, 'Main Settings') self.add_tab(self._main_layout, 'Main Settings')
def add_special_pick_parameters_tab(self): def add_special_pick_parameters_tab(self):
@ -1928,27 +1928,80 @@ class AutoPickParaBox(QtGui.QWidget):
self.add_to_layout(self._advanced_layout, 'First-motion picker', self.add_to_layout(self._advanced_layout, 'First-motion picker',
self.parameter.get_special_para_names()['fm']) self.parameter.get_special_para_names()['fm'])
self.add_to_layout(self._advanced_layout, 'Quality assessment', self.add_to_layout(self._advanced_layout, 'Quality assessment',
self.parameter.get_special_para_names()['quality'], self.parameter.get_special_para_names()['quality'])
False)
self.add_tab(self._advanced_layout, 'Advanced Settings') self.add_tab(self._advanced_layout, 'Advanced Settings')
def gen_h_seperator(self): # def gen_h_seperator(self):
seperator = QtGui.QFrame() # seperator = QtGui.QFrame()
seperator.setFrameShape(QtGui.QFrame.HLine) # seperator.setFrameShape(QtGui.QFrame.HLine)
return seperator # return seperator
def gen_headline(self, text): # def gen_headline(self, text):
label=QtGui.QLabel(text) # label=QtGui.QLabel(text)
font=QtGui.QFont() # font=QtGui.QFont()
font.setBold(True) # font.setBold(True)
label.setFont(font) # label.setFont(font)
return label # return label
def add_to_layout(self, layout, name, items, seperator=True): def add_to_layout(self, layout, name, items):
layout.addWidget(self.gen_headline(name)) groupbox = QtGui.QGroupBox(name)
layout.addLayout(self.init_boxes(items)) self.groupboxes[name] = groupbox
if seperator: groupbox.setLayout(self.init_boxes(items))
layout.addWidget(self.gen_h_seperator()) layout.addWidget(groupbox)
def show_groupboxes(self):
for name in self.groupboxes.keys():
self.show_groupbox(name)
self._advanced_cb.show()
def hide_groupboxes(self):
for name in self.groupboxes.keys():
self.hide_groupbox(name)
self._advanced_cb.hide()
def show_groupbox(self, name):
if name in self.groupboxes.keys():
self.groupboxes[name].show()
else:
print('Groupbox {} not part of object.'.format(name))
def hide_groupbox(self, name):
if name in self.groupboxes.keys():
self.groupboxes[name].hide()
else:
print('Groupbox {} not part of object.'.format(name))
def show_parameter(self, name=None):
if not name:
for name in self.boxes.keys():
self.show_parameter(name)
return
if name in self.boxes.keys() and name in self.labels.keys():
# comprising case type(self.boxes[name]) == list
boxes = self.boxes[name]
if not type(boxes) == list:
boxes = [boxes]
for box in boxes:
box.show()
self.labels[name].show()
else:
print('Parameter {} not part of object.'.format(name))
def hide_parameter(self, name=None):
if not name:
for name in self.boxes.keys():
self.hide_parameter(name)
return
if name in self.boxes.keys() and name in self.labels.keys():
# comprising case type(self.boxes[name]) == list
boxes = self.boxes[name]
if not type(boxes) == list:
boxes = [boxes]
for box in boxes:
box.hide()
self.labels[name].hide()
else:
print('Parameter {} not part of object.'.format(name))
def params_from_gui(self): def params_from_gui(self):
for param in self.parameter.get_all_para_names(): for param in self.parameter.get_all_para_names():
@ -1999,7 +2052,8 @@ class AutoPickParaBox(QtGui.QWidget):
def openFile(self): def openFile(self):
fd = QtGui.QFileDialog() fd = QtGui.QFileDialog()
fname = fd.getOpenFileName(self, 'Browse for settings file.', filter='PyLoT input file (*.in)') fname = fd.getOpenFileName(self, 'Browse for settings file.',
filter='PyLoT input file (*.in)')
if fname[0]: if fname[0]:
try: try:
self.parameter.from_file(fname[0]) self.parameter.from_file(fname[0])
@ -2010,7 +2064,8 @@ class AutoPickParaBox(QtGui.QWidget):
def saveFile(self): def saveFile(self):
fd = QtGui.QFileDialog() fd = QtGui.QFileDialog()
fname = fd.getSaveFileName(self, 'Browse for settings file.', filter='PyLoT input file (*.in)') fname = fd.getSaveFileName(self, 'Browse for settings file.',
filter='PyLoT input file (*.in)')
if fname[0]: if fname[0]:
try: try:
self.params_from_gui() self.params_from_gui()