Skip to content

Commit

Permalink
##188529406 ; Fixed issue with scroll wheel on numeric inputs; create…
Browse files Browse the repository at this point in the history
…d a console script for bcipy-params
  • Loading branch information
lawhead committed Nov 8, 2024
1 parent ad64938 commit 0c366f8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
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 0c366f8

Please sign in to comment.