Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade requirements for rc4 #299

Merged
merged 4 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bcipy/acquisition/datastream/mock/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def main(switch: Switch):
background_color='black')

ex.show_gui()
result = gui.exec_()
result = gui.exec()
switch.quit()
sys.exit(result)

Expand Down
55 changes: 34 additions & 21 deletions bcipy/gui/BCInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ class BCInterface(BCIGui):
tasks = TaskType.list()

default_text = '...'
padding = 30
padding = 20
btn_height = 40
btn_width = 100
max_length = 25
min_length = 1
timeout = 3
font = 'Consolas'

def __init__(self, *args, **kwargs):
super(BCInterface, self).__init__(*args, **kwargs)
Expand Down Expand Up @@ -63,7 +65,7 @@ def __init__(self, *args, **kwargs):

self.autoclose = False
self.alert = True
self.static_font_size = 24
self.static_font_size = 16

self.user_id_validations = [
(invalid_length(min=self.min_length, max=self.max_length),
Expand All @@ -77,36 +79,43 @@ def build_buttons(self) -> None:

Build all buttons necessary for the UI. Define their action on click using the named argument action.
"""

self.add_button(
message='Load Parameters', position=[self.padding, 450],
size=[110, self.btn_height], background_color='white',
message='Load', position=[self.padding, 450],
size=[self.btn_width, self.btn_height], background_color='Plum',
text_color='black',
font_family=self.font,
action=self.select_parameters)

self.add_button(
message='Edit Parameters', position=[self.padding + 115, 450],
size=[105, self.btn_height], background_color='white',
message='Edit', position=[self.padding + self.btn_width + 10, 450],
size=[self.btn_width, self.btn_height], background_color='LightCoral',
text_color='black',
font_family=self.font,
action=self.edit_parameters)

btn_auc_width = 100
btn_auc_x = self.padding + 225
btn_auc_x = self.padding + (self.btn_width * 2) + 20
self.add_button(
message='Calculate AUC', position=(btn_auc_x, 450),
size=(btn_auc_width, self.btn_height), background_color='white',
message='Train', position=(btn_auc_x, 450),
size=(self.btn_width, self.btn_height), background_color='LightSeaGreen',
text_color='black',
font_family=self.font,
action=self.offline_analysis)

btn_start_width = 200
btn_start_width = self.btn_width * 2 + 10
btn_start_x = self.width - (self.padding + btn_start_width)
self.add_button(
message='Start Experiment Session', position=[btn_start_x, 450],
size=[btn_start_width, self.btn_height],
message='Start Session', position=[btn_start_x, 440],
size=[btn_start_width, self.btn_height + 10],
background_color='green',
action=self.start_experiment,
text_color='white')
text_color='white',
font_family=self.font)

self.add_button(
message='+',
position=[self.width - self.padding - 200, 260],
size=[40, self.btn_height - 10],
size=[35, self.btn_height - 10],
background_color='green',
action=self.create_experiment,
text_color='white'
Expand Down Expand Up @@ -202,10 +211,11 @@ def build_text(self) -> None:
"""
self.add_static_textbox(
text='BCInterface',
position=[275, 0],
size=[200, 50],
position=[210, 0],
size=[250, 50],
background_color='black',
text_color='white',
font_family=self.font,
font_size=30)

text_x = 145
Expand All @@ -215,12 +225,14 @@ def build_text(self) -> None:
size=[200, 50],
background_color='black',
text_color='white',
font_family=self.font,
font_size=self.static_font_size)
self.add_static_textbox(
text='Experiment',
position=[text_x, 205],
size=[300, 50],
background_color='black',
font_family=self.font,
text_color='white',
font_size=self.static_font_size)
self.add_static_textbox(
Expand All @@ -229,6 +241,7 @@ def build_text(self) -> None:
size=[300, 50],
background_color='black',
text_color='white',
font_family=self.font,
font_size=self.static_font_size)

def build_images(self) -> None:
Expand Down Expand Up @@ -430,8 +443,8 @@ def action_disabled(self) -> bool:
return True
else:
self.disable = True
# set the update time to every 1000ms
self.timer.start(1000)
# set the update time to every 500ms
self.timer.start(500)
return False

def _disable_action(self) -> bool:
Expand All @@ -456,12 +469,12 @@ def start_app() -> None:
ex = BCInterface(
title='Brain Computer Interface',
height=550,
width=750,
width=700,
background_color='black')

ex.show_gui()

sys.exit(bcipy_gui.exec_())
sys.exit(bcipy_gui.exec())


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion bcipy/gui/alert.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""GUI alert messages"""
# pylint: disable=no-name-in-module
import sys
from PyQt5.QtWidgets import QApplication
from PyQt6.QtWidgets import QApplication
from bcipy.gui.main import alert_message, AlertMessageType, AlertResponse, AlertMessageResponse


Expand Down
12 changes: 6 additions & 6 deletions bcipy/gui/experiments/ExperimentField.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from typing import List

from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (
from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import (
QHBoxLayout,
QPushButton,
QScrollArea,
Expand Down Expand Up @@ -210,7 +210,7 @@ def throw_alert_message(self,
elif message_response is AlertMessageResponse.OCE:
msg.setStandardButtons(AlertResponse.OK.value | AlertResponse.CANCEL.value)

return msg.exec_()
return msg.exec()


class MainPanel(QWidget):
Expand Down Expand Up @@ -240,8 +240,8 @@ def initUI(self):
vbox = QVBoxLayout()

self.form_panel = QScrollArea()
self.form_panel.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.form_panel.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.form_panel.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
self.form_panel.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
self.form_panel.setWidgetResizable(True)
self.form_panel.setFixedWidth(self.width)
self.form_panel.setWidget(self.form)
Expand Down Expand Up @@ -307,7 +307,7 @@ def start_app() -> None:
save_path=save_path,
file_name=file_name
)
bcipy_gui.exec_()
bcipy_gui.exec()

if validate:
if validate_field_data_written(save_path, file_name):
Expand Down
2 changes: 1 addition & 1 deletion bcipy/gui/experiments/ExperimentRegistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def start_app() -> None:
width=600,
background_color='black')

sys.exit(bcipy_gui.exec_())
sys.exit(bcipy_gui.exec())


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion bcipy/gui/experiments/FieldRegistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def start_app() -> None:

ex.show_gui()

sys.exit(bcipy_gui.exec_())
sys.exit(bcipy_gui.exec())


if __name__ == '__main__':
Expand Down
7 changes: 4 additions & 3 deletions bcipy/gui/file_dialog.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# pylint: disable=no-name-in-module,missing-docstring,too-few-public-methods
import sys
from pathlib import Path
from PyQt5.QtWidgets import QApplication, QWidget, QFileDialog, QDesktopWidget
from PyQt6.QtWidgets import QApplication, QWidget, QFileDialog
from PyQt6 import QtGui
from bcipy.preferences import preferences

DEFAULT_FILE_TYPES = "All Files (*)"
Expand All @@ -12,14 +13,14 @@ class FileDialog(QWidget):

def __init__(self):
super().__init__()
self.title = 'PyQt5 file dialogs - pythonspot.com'
self.title = 'PyQt6 file dialogs - pythonspot.com'
self.width = 640
self.height = 480

# Center on screen
self.resize(self.width, self.height)
frame_geom = self.frameGeometry()
frame_geom.moveCenter(QDesktopWidget().availableGeometry().center())
frame_geom.moveCenter(QtGui.QGuiApplication.primaryScreen().availableGeometry().center())
self.move(frame_geom.topLeft())

# The native dialog may prevent the selection from closing after a
Expand Down
37 changes: 19 additions & 18 deletions bcipy/gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from enum import Enum
from typing import Any, Callable, List, NamedTuple, Optional, Tuple, Union

from PyQt5.QtCore import QEvent, Qt, QTimer, pyqtSlot
from PyQt5.QtGui import QFont, QPixmap, QShowEvent
from PyQt5.QtWidgets import (QApplication, QCheckBox, QComboBox,
from PyQt6.QtCore import Qt, QTimer, pyqtSlot
from PyQt6.QtGui import QFont, QPixmap, QShowEvent, QWheelEvent
from PyQt6.QtWidgets import (QApplication, QCheckBox, QComboBox,
QDoubleSpinBox, QFileDialog, QHBoxLayout, QLabel,
QLineEdit, QMessageBox, QPushButton, QScrollArea,
QSpinBox, QVBoxLayout, QWidget)
Expand All @@ -19,7 +19,7 @@

def font(size: int = 14, font_family: str = 'Helvetica') -> QFont:
"""Create a Font object with the given parameters."""
return QFont(font_family, size, QFont.Normal)
return QFont(font_family, size, weight=0)


def invalid_length(min=1, max=25) -> bool:
Expand Down Expand Up @@ -68,21 +68,21 @@ class AlertMessageType(Enum):

Custom enum used to abstract PyQT message types from downstream users.
"""
WARN = QMessageBox.Warning
QUESTION = QMessageBox.Question
INFO = QMessageBox.Information
CRIT = QMessageBox.Critical
WARN = QMessageBox.Icon.Warning
QUESTION = QMessageBox.Icon.Question
INFO = QMessageBox.Icon.Information
CRIT = QMessageBox.Icon.Critical


class AlertResponse(Enum):
"""Alert Response.

Custom enum used to abstract PyQT alert responses from downstream users.
"""
OK = QMessageBox.Ok
CANCEL = QMessageBox.Cancel
YES = QMessageBox.Yes
NO = QMessageBox.No
OK = QMessageBox.StandardButton.Ok
CANCEL = QMessageBox.StandardButton.Cancel
YES = QMessageBox.StandardButton.Yes
NO = QMessageBox.StandardButton.No


class PushButton(QPushButton):
Expand Down Expand Up @@ -245,7 +245,7 @@ def __init__(self,

def eventFilter(self, source, event):
"""Event filter that suppresses the scroll wheel event."""
if (event.type() == QEvent.Wheel and source is self.control):
if (event.type() == QWheelEvent and source is self.control):
return True
return False

Expand Down Expand Up @@ -827,6 +827,7 @@ def add_button(self,
id: int = -1,
background_color: str = 'white',
text_color: str = 'default',
font_family: str = 'Times',
action: Optional[Callable] = None) -> PushButton:
"""Add Button."""
btn = PushButton(message, self.window)
Expand All @@ -835,7 +836,7 @@ def add_button(self,
btn.resize(size[0], size[1])

btn.setStyleSheet(
f'background-color: {background_color}; color: {text_color};')
f'background-color: {background_color}; color: {text_color}; font-family: {font_family};')

if action:
btn.clicked.connect(action)
Expand Down Expand Up @@ -948,7 +949,7 @@ def throw_alert_message(
message_type=message_type,
message_response=message_response,
message_timeout=message_timeout)
return msg.exec_()
return msg.exec()

def get_filename_dialog(self,
message: str = 'Open File',
Expand Down Expand Up @@ -983,8 +984,8 @@ def __init__(self,

# create the scrollable are
self.frame = QScrollArea()
self.frame.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.frame.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.frame.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
self.frame.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
self.frame.setWidgetResizable(True)
self.frame.setFixedWidth(self.width)
self.setFixedHeight(self.height)
Expand Down Expand Up @@ -1109,7 +1110,7 @@ def start_app() -> None:
message_response=AlertMessageResponse.OCE,
message_timeout=5)

sys.exit(bcipy_gui.exec_())
sys.exit(bcipy_gui.exec())


if __name__ == '__main__':
Expand Down
14 changes: 7 additions & 7 deletions bcipy/gui/parameters/params_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from pathlib import Path
from typing import Dict, Tuple

from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (QApplication, QFileDialog, QHBoxLayout,
from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import (QApplication, QFileDialog, QHBoxLayout,
QPushButton, QScrollArea, QVBoxLayout, QWidget)

from bcipy.config import BCIPY_ROOT
Expand Down Expand Up @@ -244,8 +244,8 @@ def __init__(self, json_file: str):
self.layout = QVBoxLayout()

self.changes_area = QScrollArea()
self.changes_area.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.changes_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.changes_area.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
self.changes_area.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
self.changes_area.setWidgetResizable(True)
self.changes_area.setWidget(self.change_items)
self.changes_area.setVisible(not self.collapsed)
Expand Down Expand Up @@ -328,8 +328,8 @@ def initUI(self):
vbox.addLayout(self.changes_panel)

self.form_panel = QScrollArea()
self.form_panel.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.form_panel.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.form_panel.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
self.form_panel.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
self.form_panel.setWidgetResizable(True)
self.form_panel.setFixedWidth(self.size[0])
self.form_panel.setWidget(self.form)
Expand Down Expand Up @@ -423,7 +423,7 @@ def main(json_file, title='BCI Parameters', size=(450, 550)):
"""Set up the GUI components and start the main loop."""
app = QApplication(sys.argv)
_panel = MainPanel(json_file, title, size)
sys.exit(app.exec_())
sys.exit(app.exec())


if __name__ == '__main__':
Expand Down
Loading
Loading