コード例 #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()