Beispiel #1
0
    def __init__(self, parent, target, feat):
        super().__init__(parent)
        self._feat = feat

        layout = QtGui.QHBoxLayout(self)

        if feat.keys:
            wid = QtGui.QComboBox()
            if isinstance(feat.keys, dict):
                self._keys = list(feat.keys.keys())
            else:
                self._keys = list(feat.keys)

            wid.addItems([str(key) for key in self._keys])
            wid.currentIndexChanged.connect(self._combobox_changed)
        else:
            wid = QtGui.QLineEdit()
            wid.textChanged.connect(self._lineedit_changed)

        layout.addWidget(wid)
        self._key_widget = wid

        wid = WidgetMixin.from_feat(feat)
        wid.bind_feat(feat)
        wid.feat_key = self._keys[0]
        wid.lantz_target = target
        layout.addWidget(wid)
        self._value_widget = wid
Beispiel #2
0
    def __init__(self, parent, target):
        super().__init__(parent)
        self._lantz_target = target

        layout = QtGui.QVBoxLayout(self)

        label = QtGui.QLabel()
        label.setText(str(target))
        layout.addWidget(label)

        recall = QtGui.QPushButton()
        recall.setText('Refresh')
        recall.clicked.connect(lambda x: target.refresh())

        update = QtGui.QPushButton()
        update.setText('Update')
        update.clicked.connect(
            lambda x: target.update(self.widgets_values_as_dict()))

        auto = QtGui.QCheckBox()
        auto.setText('Update on change')
        auto.setChecked(True)
        auto.stateChanged.connect(self.update_on_change)

        hlayout = QtGui.QHBoxLayout()
        hlayout.addWidget(recall)
        hlayout.addWidget(update)
        hlayout.addWidget(auto)

        layout.addLayout(hlayout)

        self.writable_widgets = []
        self.widgets = []

        # Feat
        for feat_name, feat in sorted(target.feats.items()):
            try:
                feat_widget = LabeledFeatWidget(self, target, feat)

                self.widgets.append(feat_widget)
                if feat_widget.writable:
                    self.writable_widgets.append(feat_widget)

                layout.addWidget(feat_widget)
            except Exception as ex:
                logger.debug('Could not create control for {}: {}'.format(
                    feat_name, ex))
                if __PRINT_TRACEBACK__:
                    import traceback
                    traceback.print_exc()

        # Actions
        line = QtGui.QFrame(self)
        #self.line.setGeometry(QtCore.QRect(110, 80, 351, 31))
        line.setFrameShape(QtGui.QFrame.HLine)
        line.setFrameShadow(QtGui.QFrame.Sunken)
        layout.addWidget(line)

        actions_label = QtGui.QLabel(self)
        actions_label.setText('Actions:')
        actions_label.setFixedWidth(120)

        self.actions_combo = QtGui.QComboBox(self)
        self.actions_combo.addItems(list(target.actions.keys()))

        actions_button = QtGui.QPushButton(self)
        actions_button.setFixedWidth(60)
        actions_button.setText('Run')
        actions_button.clicked.connect(self.on_run_clicked)

        alayout = QtGui.QHBoxLayout()
        alayout.addWidget(actions_label)
        alayout.addWidget(self.actions_combo)
        alayout.addWidget(actions_button)

        layout.addLayout(alayout)