Пример #1
0
    def _init_ui(self, history):
        self.gb_history = QtWidgets.QGroupBox('History')
        self.tw_cutoff = CutoffHistoryTable(history)
        self.pb_ok = QtWidgets.QPushButton('Ok')
        self.pb_ok.setEnabled(False)
        self.pb_cancel = QtWidgets.QPushButton('Cancel')

        self.la_main = QtWidgets.QVBoxLayout()
        self.la_history = QtWidgets.QVBoxLayout()
        self.la_ok_cancel = QtWidgets.QHBoxLayout()
        self.la_main.addWidget(self.gb_history)
        self.la_history.addWidget(self.tw_cutoff)
        self.la_ok_cancel.addStretch()
        self.la_ok_cancel.addWidget(self.pb_ok)
        self.la_ok_cancel.addStretch()
        self.la_ok_cancel.addWidget(self.pb_cancel)
        self.la_ok_cancel.addStretch()
        self.la_ok_cancel.setContentsMargins(0, 0, 0, 0)
        self.la_main.addLayout(self.la_ok_cancel)
        self.la_main.setSizeConstraint(QtWidgets.QLayout.SetFixedSize)
        self.gb_history.setLayout(self.la_history)
        self.setLayout(self.la_main)

        self.tw_cutoff.itemSelectionChanged.connect(
            lambda *args: self.pb_ok.setEnabled(len(self.tw_cutoff.selectedIndexes()) > 0)
        )
        self.pb_ok.clicked.connect(lambda event: self.accept())
        self.pb_cancel.clicked.connect(lambda event: self.reject())
Пример #2
0
    def __init__(self, parent, cfg):
        QtWidgets.QWidget.__init__(self, parent)
        self._config = cfg
        self.values = OrderedDict(
            (('std_cutoff_radius', 'default cutoff radius'), ))

        self.lineedit_dict = {}
        box = QtWidgets.QVBoxLayout()
        grid = QtWidgets.QGridLayout()
        for i, (attr_str, label) in enumerate(self.values.iteritems()):
            cfg_comp = getattr(self._config, 'Computation')

            l = QtWidgets.QLabel(label, self)
            t = QtWidgets.QLineEdit(self)
            t.setText(str(getattr(cfg_comp, attr_str)))
            self.lineedit_dict[attr_str] = t

            # self.connect(t, QtCore.SIGNAL("editingFinished()"), lambda who=attr_str: self.value_edited(who))
            t.textChanged.connect(self.any_change)
            grid.addWidget(l, i, 0)
            grid.addWidget(t, i, 1)

        self.tw_cutoff_history = CutoffHistoryTable(cutoff_history.history)
        pb_clear_cutoff_history = QtWidgets.QPushButton(
            self.style().standardIcon(QtWidgets.QStyle.SP_TrashIcon),
            'Clear cutoff history')
        pb_clear_cutoff_history.clicked.connect(
            self.clear_cutoff_history_requested)
        if len(cutoff_history.history) == 0:
            self.tw_cutoff_history.setVisible(False)
            pb_clear_cutoff_history.setVisible(False)

        self.tw_cutoff_presets = CutoffPresetTable(cutoff_presets.presets)
        pb_clear_cutoff_presets = QtWidgets.QPushButton(
            self.style().standardIcon(QtWidgets.QStyle.SP_TrashIcon),
            'Clear cutoff presets')
        pb_clear_cutoff_presets.clicked.connect(
            self.clear_cutoff_presets_requested)
        if len(cutoff_presets.presets) == 0:
            self.tw_cutoff_presets.setVisible(False)
            pb_clear_cutoff_presets.setVisible(False)

        box.addLayout(grid)
        box.addWidget(self.tw_cutoff_history, 0, QtCore.Qt.AlignHCenter)
        box.addWidget(pb_clear_cutoff_history, 0, QtCore.Qt.AlignRight)
        box.addWidget(self.tw_cutoff_presets, 0, QtCore.Qt.AlignHCenter)
        box.addWidget(pb_clear_cutoff_presets, 0, QtCore.Qt.AlignRight)
        box.addStretch()
        self.setLayout(box)
        self.show()
Пример #3
0
class CutoffHistoryDialog(QtWidgets.QDialog):
    def __init__(self, parent, elements, preferred_filenames_with_frames=None):
        super(CutoffHistoryDialog, self).__init__(parent)
        history = cutoff_history.filtered_history(elements,
                                                  preferred_filenames_with_frames=preferred_filenames_with_frames)
        self._init_ui(history)

    def _init_ui(self, history):
        self.gb_history = QtWidgets.QGroupBox('History')
        self.tw_cutoff = CutoffHistoryTable(history)
        self.pb_ok = QtWidgets.QPushButton('Ok')
        self.pb_ok.setEnabled(False)
        self.pb_cancel = QtWidgets.QPushButton('Cancel')

        self.la_main = QtWidgets.QVBoxLayout()
        self.la_history = QtWidgets.QVBoxLayout()
        self.la_ok_cancel = QtWidgets.QHBoxLayout()
        self.la_main.addWidget(self.gb_history)
        self.la_history.addWidget(self.tw_cutoff)
        self.la_ok_cancel.addStretch()
        self.la_ok_cancel.addWidget(self.pb_ok)
        self.la_ok_cancel.addStretch()
        self.la_ok_cancel.addWidget(self.pb_cancel)
        self.la_ok_cancel.addStretch()
        self.la_ok_cancel.setContentsMargins(0, 0, 0, 0)
        self.la_main.addLayout(self.la_ok_cancel)
        self.la_main.setSizeConstraint(QtWidgets.QLayout.SetFixedSize)
        self.gb_history.setLayout(self.la_history)
        self.setLayout(self.la_main)

        self.tw_cutoff.itemSelectionChanged.connect(
            lambda *args: self.pb_ok.setEnabled(len(self.tw_cutoff.selectedIndexes()) > 0)
        )
        self.pb_ok.clicked.connect(lambda event: self.accept())
        self.pb_cancel.clicked.connect(lambda event: self.reject())

    def accept(self):
        cutoff_history.remove_list(self.tw_cutoff.history_entries_for_deletion)
        cutoff_history.save()
        return super(CutoffHistoryDialog, self).accept()

    @property
    def history(self):
        return self.tw_cutoff.history

    @property
    def selected_radii(self):
        return self.history[self.tw_cutoff.selectedIndexes()[0].row()].radii
Пример #4
0
    def __init__(self, parent, cfg):
        QtWidgets.QWidget.__init__(self, parent)
        self._config = cfg
        self.values = OrderedDict((('std_cutoff_radius', 'default cutoff radius'), ))

        self.lineedit_dict = {}
        box = QtWidgets.QVBoxLayout()
        grid = QtWidgets.QGridLayout()
        for i, (attr_str, label) in enumerate(self.values.iteritems()):
            cfg_comp = getattr(self._config, 'Computation')

            l = QtWidgets.QLabel(label, self)
            t = QtWidgets.QLineEdit(self)
            t.setText(str(getattr(cfg_comp, attr_str)))
            self.lineedit_dict[attr_str] = t

            # self.connect(t, QtCore.SIGNAL("editingFinished()"), lambda who=attr_str: self.value_edited(who))
            t.textChanged.connect(self.any_change)
            grid.addWidget(l, i, 0)
            grid.addWidget(t, i, 1)

        self.tw_cutoff_history = CutoffHistoryTable(cutoff_history.history)
        pb_clear_cutoff_history = QtWidgets.QPushButton(self.style().standardIcon(QtWidgets.QStyle.SP_TrashIcon),
                                                    'Clear cutoff history')
        pb_clear_cutoff_history.clicked.connect(self.clear_cutoff_history_requested)
        if len(cutoff_history.history) == 0:
            self.tw_cutoff_history.setVisible(False)
            pb_clear_cutoff_history.setVisible(False)

        self.tw_cutoff_presets = CutoffPresetTable(cutoff_presets.presets)
        pb_clear_cutoff_presets = QtWidgets.QPushButton(self.style().standardIcon(QtWidgets.QStyle.SP_TrashIcon),
                                                    'Clear cutoff presets')
        pb_clear_cutoff_presets.clicked.connect(self.clear_cutoff_presets_requested)
        if len(cutoff_presets.presets) == 0:
            self.tw_cutoff_presets.setVisible(False)
            pb_clear_cutoff_presets.setVisible(False)

        box.addLayout(grid)
        box.addWidget(self.tw_cutoff_history, 0, QtCore.Qt.AlignHCenter)
        box.addWidget(pb_clear_cutoff_history, 0, QtCore.Qt.AlignRight)
        box.addWidget(self.tw_cutoff_presets, 0, QtCore.Qt.AlignHCenter)
        box.addWidget(pb_clear_cutoff_presets, 0, QtCore.Qt.AlignRight)
        box.addStretch()
        self.setLayout(box)
        self.show()
Пример #5
0
class ComputationSettingsPage(QtWidgets.QWidget):

    def __init__(self, parent, cfg):
        QtWidgets.QWidget.__init__(self, parent)
        self._config = cfg
        self.values = OrderedDict((('std_cutoff_radius', 'default cutoff radius'), ))

        self.lineedit_dict = {}
        box = QtWidgets.QVBoxLayout()
        grid = QtWidgets.QGridLayout()
        for i, (attr_str, label) in enumerate(self.values.iteritems()):
            cfg_comp = getattr(self._config, 'Computation')

            l = QtWidgets.QLabel(label, self)
            t = QtWidgets.QLineEdit(self)
            t.setText(str(getattr(cfg_comp, attr_str)))
            self.lineedit_dict[attr_str] = t

            # self.connect(t, QtCore.SIGNAL("editingFinished()"), lambda who=attr_str: self.value_edited(who))
            t.textChanged.connect(self.any_change)
            grid.addWidget(l, i, 0)
            grid.addWidget(t, i, 1)

        self.tw_cutoff_history = CutoffHistoryTable(cutoff_history.history)
        pb_clear_cutoff_history = QtWidgets.QPushButton(self.style().standardIcon(QtWidgets.QStyle.SP_TrashIcon),
                                                    'Clear cutoff history')
        pb_clear_cutoff_history.clicked.connect(self.clear_cutoff_history_requested)
        if len(cutoff_history.history) == 0:
            self.tw_cutoff_history.setVisible(False)
            pb_clear_cutoff_history.setVisible(False)

        self.tw_cutoff_presets = CutoffPresetTable(cutoff_presets.presets)
        pb_clear_cutoff_presets = QtWidgets.QPushButton(self.style().standardIcon(QtWidgets.QStyle.SP_TrashIcon),
                                                    'Clear cutoff presets')
        pb_clear_cutoff_presets.clicked.connect(self.clear_cutoff_presets_requested)
        if len(cutoff_presets.presets) == 0:
            self.tw_cutoff_presets.setVisible(False)
            pb_clear_cutoff_presets.setVisible(False)

        box.addLayout(grid)
        box.addWidget(self.tw_cutoff_history, 0, QtCore.Qt.AlignHCenter)
        box.addWidget(pb_clear_cutoff_history, 0, QtCore.Qt.AlignRight)
        box.addWidget(self.tw_cutoff_presets, 0, QtCore.Qt.AlignHCenter)
        box.addWidget(pb_clear_cutoff_presets, 0, QtCore.Qt.AlignRight)
        box.addStretch()
        self.setLayout(box)
        self.show()

    def clear_cutoff_history_requested(self):
        message = QtWidgets.QMessageBox()
        message.setStandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
        message.setText('Do you really want to clear the cutoff radii history for all previous done calculations?\n\n' +
                        '(The history data will be cleared when you hit the ok button of the settings dialog.)')
        answer = message.exec_()
        if answer == QtWidgets.QMessageBox.Yes:
            self.tw_cutoff_history.clear_entries()

    def clear_cutoff_presets_requested(self):
        message = QtWidgets.QMessageBox()
        message.setStandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
        message.setText('Do you really want to delete all cutoff presets?\n\n' +
                        '(The presets will be removed irrevocably when you hit the ok button of the settings dialog.)')
        answer = message.exec_()
        if answer == QtWidgets.QMessageBox.Yes:
            self.tw_cutoff_presets.clear_entries()

    def any_change(self):
        cfg_comp = getattr(self._config, 'Computation')
        for i, (attr_str, label) in enumerate(self.values.iteritems()):
            setattr(cfg_comp, attr_str, float(self.lineedit_dict[attr_str].text()))
Пример #6
0
class ComputationSettingsPage(QtWidgets.QWidget):
    def __init__(self, parent, cfg):
        QtWidgets.QWidget.__init__(self, parent)
        self._config = cfg
        self.values = OrderedDict(
            (('std_cutoff_radius', 'default cutoff radius'), ))

        self.lineedit_dict = {}
        box = QtWidgets.QVBoxLayout()
        grid = QtWidgets.QGridLayout()
        for i, (attr_str, label) in enumerate(self.values.iteritems()):
            cfg_comp = getattr(self._config, 'Computation')

            l = QtWidgets.QLabel(label, self)
            t = QtWidgets.QLineEdit(self)
            t.setText(str(getattr(cfg_comp, attr_str)))
            self.lineedit_dict[attr_str] = t

            # self.connect(t, QtCore.SIGNAL("editingFinished()"), lambda who=attr_str: self.value_edited(who))
            t.textChanged.connect(self.any_change)
            grid.addWidget(l, i, 0)
            grid.addWidget(t, i, 1)

        self.tw_cutoff_history = CutoffHistoryTable(cutoff_history.history)
        pb_clear_cutoff_history = QtWidgets.QPushButton(
            self.style().standardIcon(QtWidgets.QStyle.SP_TrashIcon),
            'Clear cutoff history')
        pb_clear_cutoff_history.clicked.connect(
            self.clear_cutoff_history_requested)
        if len(cutoff_history.history) == 0:
            self.tw_cutoff_history.setVisible(False)
            pb_clear_cutoff_history.setVisible(False)

        self.tw_cutoff_presets = CutoffPresetTable(cutoff_presets.presets)
        pb_clear_cutoff_presets = QtWidgets.QPushButton(
            self.style().standardIcon(QtWidgets.QStyle.SP_TrashIcon),
            'Clear cutoff presets')
        pb_clear_cutoff_presets.clicked.connect(
            self.clear_cutoff_presets_requested)
        if len(cutoff_presets.presets) == 0:
            self.tw_cutoff_presets.setVisible(False)
            pb_clear_cutoff_presets.setVisible(False)

        box.addLayout(grid)
        box.addWidget(self.tw_cutoff_history, 0, QtCore.Qt.AlignHCenter)
        box.addWidget(pb_clear_cutoff_history, 0, QtCore.Qt.AlignRight)
        box.addWidget(self.tw_cutoff_presets, 0, QtCore.Qt.AlignHCenter)
        box.addWidget(pb_clear_cutoff_presets, 0, QtCore.Qt.AlignRight)
        box.addStretch()
        self.setLayout(box)
        self.show()

    def clear_cutoff_history_requested(self):
        message = QtWidgets.QMessageBox()
        message.setStandardButtons(QtWidgets.QMessageBox.Yes
                                   | QtWidgets.QMessageBox.No)
        message.setText(
            'Do you really want to clear the cutoff radii history for all previous done calculations?\n\n'
            +
            '(The history data will be cleared when you hit the ok button of the settings dialog.)'
        )
        answer = message.exec_()
        if answer == QtWidgets.QMessageBox.Yes:
            self.tw_cutoff_history.clear_entries()

    def clear_cutoff_presets_requested(self):
        message = QtWidgets.QMessageBox()
        message.setStandardButtons(QtWidgets.QMessageBox.Yes
                                   | QtWidgets.QMessageBox.No)
        message.setText(
            'Do you really want to delete all cutoff presets?\n\n' +
            '(The presets will be removed irrevocably when you hit the ok button of the settings dialog.)'
        )
        answer = message.exec_()
        if answer == QtWidgets.QMessageBox.Yes:
            self.tw_cutoff_presets.clear_entries()

    def any_change(self):
        cfg_comp = getattr(self._config, 'Computation')
        for i, (attr_str, label) in enumerate(self.values.iteritems()):
            setattr(cfg_comp, attr_str,
                    float(self.lineedit_dict[attr_str].text()))