Skip to content

Commit

Permalink
Merge pull request #364 from CAMBI-tech/params-form-spaces
Browse files Browse the repository at this point in the history
Params Form fixes
  • Loading branch information
lawhead authored Nov 13, 2024
2 parents d1be1f9 + d8a3329 commit d91a878
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
6 changes: 3 additions & 3 deletions bcipy/gui/BCInterface.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 4 additions & 0 deletions bcipy/gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
19 changes: 10 additions & 9 deletions bcipy/gui/parameters/params_form.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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()
11 changes: 6 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

class UploadCommand(Command):
"""Support setup.py upload.
Modified from https://github.com/kennethreitz/setup.py
"""

Expand Down Expand Up @@ -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,
Expand All @@ -132,4 +133,4 @@ def run(self):
cmdclass={
'upload': UploadCommand,
},
)
)

0 comments on commit d91a878

Please sign in to comment.