From 0c366f8714148701beea4e57b46f3cfa64b4ac0b Mon Sep 17 00:00:00 2001 From: lawhead Date: Fri, 8 Nov 2024 14:39:08 -0800 Subject: [PATCH 1/3] ##188529406 ; Fixed issue with scroll wheel on numeric inputs; created a console script for bcipy-params --- bcipy/gui/main.py | 4 ++++ bcipy/gui/parameters/params_form.py | 19 ++++++++++--------- setup.py | 11 ++++++----- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/bcipy/gui/main.py b/bcipy/gui/main.py index 9d032dfa..b6455338 100644 --- a/bcipy/gui/main.py +++ b/bcipy/gui/main.py @@ -366,6 +366,7 @@ def init_control(self, value): spin_box = QSpinBox() spin_box.setMinimum(-100000) spin_box.setMaximum(100000) + spin_box.wheelEvent = lambda event: None # disable scroll wheel if value: spin_box.setValue(int(value)) return spin_box @@ -424,6 +425,7 @@ def init_control(self, value): spin_box.setDecimals(props.decimals) spin_box.setSingleStep(props.step) spin_box.setValue(float(value)) + spin_box.wheelEvent = lambda event: None # disable scroll wheel return spin_box def cast_value(self) -> float: @@ -656,6 +658,7 @@ def float_input(self, value: float) -> QWidget: spin_box.setDecimals(props.decimals) spin_box.setSingleStep(props.step) spin_box.setValue(value) + spin_box.wheelEvent = lambda event: None # disable scroll wheel return spin_box def int_input(self, value: int) -> QWidget: @@ -666,6 +669,7 @@ def int_input(self, value: int) -> QWidget: -100000 if self.input_min is None else self.input_min) spin_box.setMaximum( 100000 if self.input_max is None else self.input_max) + spin_box.wheelEvent = lambda event: None # disable scroll wheel if value: spin_box.setValue(value) return spin_box diff --git a/bcipy/gui/parameters/params_form.py b/bcipy/gui/parameters/params_form.py index 602d6a81..4c243f76 100644 --- a/bcipy/gui/parameters/params_form.py +++ b/bcipy/gui/parameters/params_form.py @@ -1,5 +1,6 @@ """GUI form for editing a Parameters file.""" # pylint: disable=E0611 +import argparse import sys from datetime import datetime from pathlib import Path @@ -9,7 +10,7 @@ from PyQt6.QtWidgets import (QApplication, QFileDialog, QHBoxLayout, QPushButton, QScrollArea, QVBoxLayout, QWidget) -from bcipy.config import BCIPY_ROOT +from bcipy.config import BCIPY_ROOT, DEFAULT_PARAMETERS_PATH from bcipy.gui.main import (BoolInput, DirectoryInput, FileInput, FloatInput, FormInput, IntegerInput, RangeInput, SearchInput, SelectionInput, TextInput, static_text_control) @@ -423,7 +424,7 @@ def on_save_as(self): self.repaint() -def main(json_file, title='BCI Parameters', size=(750, 800)) -> str: +def init(json_file, title='BCI Parameters', size=(750, 800)) -> str: """Set up the GUI components and start the main loop.""" app = QApplication(sys.argv) panel = MainPanel(json_file, title, size) @@ -433,12 +434,8 @@ def main(json_file, title='BCI Parameters', size=(750, 800)) -> str: return json_file -if __name__ == '__main__': - - import argparse - - from bcipy.config import DEFAULT_PARAMETERS_PATH - +def main(): + """Process command line arguments and initialize the GUI.""" parser = argparse.ArgumentParser() # Command line utility for adding arguments/ paths via command line @@ -449,4 +446,8 @@ def main(json_file, title='BCI Parameters', size=(750, 800)) -> str: args = parser.parse_args() # Note that this write to stdout is important for the interaction with # the BCInterface main GUI. - print(main(args.parameters), file=sys.stdout) + print(init(args.parameters), file=sys.stdout) + + +if __name__ == '__main__': + main() diff --git a/setup.py b/setup.py index 9c213b15..167bacdb 100644 --- a/setup.py +++ b/setup.py @@ -51,7 +51,7 @@ class UploadCommand(Command): """Support setup.py upload. - + Modified from https://github.com/kennethreitz/setup.py """ @@ -106,12 +106,13 @@ def run(self): 'data', )), entry_points={ - 'console_scripts': - [ + 'console_scripts': [ 'bcipy = bcipy.main:bcipy_main', 'bcipy-erp-viz = bcipy.helpers.visualization:erp', 'bcipy-sim = bcipy.simulator:main', - "bcipy-train = bcipy.signal.model.offline_analysis:main"], + 'bcipy-train = bcipy.signal.model.offline_analysis:main', + 'bcipy-params = bcipy.gui.parameters.params_form:main' + ], }, install_requires=REQUIRED, include_package_data=True, @@ -132,4 +133,4 @@ def run(self): cmdclass={ 'upload': UploadCommand, }, -) \ No newline at end of file +) From 6c742a30be94c85dc216c185514e2407ab0954d9 Mon Sep 17 00:00:00 2001 From: lawhead Date: Mon, 11 Nov 2024 15:42:25 -0800 Subject: [PATCH 2/3] Quote pathname when loading the params_form from BCInterface to handle paths with spaces --- bcipy/gui/BCInterface.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bcipy/gui/BCInterface.py b/bcipy/gui/BCInterface.py index 3a4c7913..ae7a7892 100644 --- a/bcipy/gui/BCInterface.py +++ b/bcipy/gui/BCInterface.py @@ -1,10 +1,10 @@ +import logging import subprocess import sys -import logging from typing import List from bcipy.config import (BCIPY_ROOT, DEFAULT_PARAMETERS_PATH, - STATIC_IMAGES_PATH, PROTOCOL_LOG_FILENAME) + PROTOCOL_LOG_FILENAME, STATIC_IMAGES_PATH) from bcipy.gui.main import (AlertMessageResponse, AlertMessageType, AlertResponse, BCIGui, app, contains_special_characters, contains_whitespaces, @@ -316,7 +316,7 @@ def edit_parameters(self) -> None: return None output = subprocess.check_output( - f'python {BCIPY_ROOT}/gui/parameters/params_form.py -p {self.parameter_location}', + f'python {BCIPY_ROOT}/gui/parameters/params_form.py -p "{self.parameter_location}"', shell=True) if output: self.parameter_location = output.decode().strip() From d8a3329d1bbc022ec519d424609f414e3b9f2047 Mon Sep 17 00:00:00 2001 From: lawhead Date: Tue, 12 Nov 2024 16:09:24 -0800 Subject: [PATCH 3/3] Updated GUI code to use new command for loading the params-form --- bcipy/gui/BCInterface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bcipy/gui/BCInterface.py b/bcipy/gui/BCInterface.py index ae7a7892..bfacafad 100644 --- a/bcipy/gui/BCInterface.py +++ b/bcipy/gui/BCInterface.py @@ -316,7 +316,7 @@ def edit_parameters(self) -> None: return None output = subprocess.check_output( - f'python {BCIPY_ROOT}/gui/parameters/params_form.py -p "{self.parameter_location}"', + f'bcipy-params -p "{self.parameter_location}"', shell=True) if output: self.parameter_location = output.decode().strip()