[change] structure changed to make parabox more flexible

This commit is contained in:
Marcel Paffrath 2017-06-22 11:03:24 +02:00
parent 203974cd83
commit f91e1cde6f
3 changed files with 18 additions and 7 deletions

View File

@ -799,7 +799,7 @@ class MainWindow(QMainWindow):
self.paraBox.setValue(box, dirs[directory]) self.paraBox.setValue(box, dirs[directory])
#show needed parameter in box #show needed parameter in box
self.paraBox.show_parameter(directory) self.paraBox.show_parameter(directory)
dirs_box = self.paraBox.get_groupbox_exclusive('Directories') dirs_box = self.paraBox.get_groupbox_dialog('Directories')
if not dirs_box.exec_(): if not dirs_box.exec_():
return return
self.project.rootpath = dirs['rootpath'] self.project.rootpath = dirs['rootpath']

View File

@ -1 +1 @@
9f16-dirty 2039-dirty

View File

@ -1987,6 +1987,7 @@ class AutoPickParaBox(QtGui.QWidget):
self.labels = {} self.labels = {}
self.boxes = {} self.boxes = {}
self.groupboxes = {} self.groupboxes = {}
self._exclusive_widgets = []
self._init_sublayouts() self._init_sublayouts()
self.setLayout(self.layout) self.setLayout(self.layout)
self.add_main_parameters_tab() self.add_main_parameters_tab()
@ -2168,20 +2169,29 @@ 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)
layout = QtGui.QVBoxLayout()
widget.setLayout(layout)
layout.addWidget(self.groupboxes[name])
self._exclusive_widgets.append(widget)
return widget
def get_groupbox_dialog(self, name):
widget = self.get_groupbox_exclusive(name)
dialog = QtGui.QDialog(self.parent()) dialog = QtGui.QDialog(self.parent())
buttonbox = QtGui.QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel)
self._exclusive_dialog = dialog
layout = QtGui.QVBoxLayout() layout = QtGui.QVBoxLayout()
dialog.setLayout(layout) dialog.setLayout(layout)
layout.addWidget(self.groupboxes[name]) buttonbox = QtGui.QDialogButtonBox(QDialogButtonBox.Ok |
layout.addWidget(buttonbox) QDialogButtonBox.Cancel)
buttonbox.accepted.connect(dialog.accept) buttonbox.accepted.connect(dialog.accept)
buttonbox.accepted.connect(self.refresh) buttonbox.accepted.connect(self.refresh)
buttonbox.accepted.connect(self.params_from_gui) buttonbox.accepted.connect(self.params_from_gui)
buttonbox.rejected.connect(dialog.reject) buttonbox.rejected.connect(dialog.reject)
buttonbox.rejected.connect(self.refresh) buttonbox.rejected.connect(self.refresh)
buttonbox.rejected.connect(self.params_to_gui) buttonbox.rejected.connect(self.params_to_gui)
layout.addWidget(widget)
layout.addWidget(buttonbox)
self._exclusive_dialog = dialog
return dialog return dialog
def add_to_layout(self, layout, name, items, position): def add_to_layout(self, layout, name, items, position):
@ -2342,6 +2352,7 @@ class AutoPickParaBox(QtGui.QWidget):
self.show_parameter() self.show_parameter()
if hasattr(self, '_exclusive_dialog'): if hasattr(self, '_exclusive_dialog'):
self._exclusive_dialog.close() self._exclusive_dialog.close()
self._exclusive_widgets = []
QtGui.QWidget.show(self) QtGui.QWidget.show(self)
def _warn(self, message): def _warn(self, message):