Exemplo n.º 1
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()
Exemplo n.º 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()
Exemplo n.º 3
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()))
Exemplo n.º 4
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()))