コード例 #1
0
ファイル: widgets.py プロジェクト: chstan/daquiri
class SpinBox(QSpinBox, Subjective):
    def __init__(self, *args, subject=None, **kwargs):
        super().__init__(*args, **kwargs)

        self.subject = subject
        if self.subject is None:
            self.subject = BehaviorSubject(self.value())

        self.valueChanged.connect(self.subject.on_next)
        self.subject.subscribe(self.update_ui)

    def update_ui(self, value):
        self.setValue(value)
コード例 #2
0
ファイル: widgets.py プロジェクト: chstan/daquiri
class ComboBox(QComboBox, Subjective):
    def __init__(self, *args, subject=None, **kwargs):
        super().__init__(*args, **kwargs)

        self.subject = subject
        if self.subject is None:
            self.subject = BehaviorSubject(self.currentData())

        self.currentIndexChanged.connect(
            lambda: self.subject.on_next(self.currentText()))
        self.subject.subscribe(self.update_ui)

    def update_ui(self, value):
        if self.currentText() != value:
            self.setCurrentText(value)
コード例 #3
0
ファイル: widgets.py プロジェクト: chstan/daquiri
class LineEdit(QLineEdit, Subjective):
    def __init__(self, *args, subject=None, process_on_next=None):
        super().__init__(*args)

        self.subject = subject
        self.process_on_next = process_on_next
        if self.subject is None:
            self.subject = BehaviorSubject(self.text())

        self.textChanged[str].connect(self.subject.on_next)
        self.subject.subscribe(self.update_ui)

    def update_ui(self, value):
        if self.process_on_next:
            value = self.process_on_next(value)

        if value != self.text():
            self.setText(value)
コード例 #4
0
ファイル: sensor_wrapper.py プロジェクト: kyr7/vizzero
 def __init__(self, rx_sensor_settings_subject: BehaviorSubject):
     self.sensor_settings = rx_sensor_settings_subject.value
     self.rx_sensor_settings_subject_subscription = rx_sensor_settings_subject.subscribe(self.set_sensor_settings)
     if self.sensor_settings.simulation:
         self.board_id = BoardIds.SYNTHETIC_BOARD.value
     else:
         self.board_id = BoardIds.CYTON_BOARD.value
         self.params.serial_port = self.sensor_settings.sensor_com_port
     self.board = BoardShim(self.board_id, self.params)
     self.channels_idx = BoardShim.get_emg_channels(self.board_id)
     self.buffer = np.empty([0, NUM_CHANNELS])
     self.board.prepare_session()
     self.board.start_stream()