From 81f10d2ff751cd950bb714b11b447779de8e4567 Mon Sep 17 00:00:00 2001 From: Andres Torres <34612646+Ahsoka@users.noreply.github.com> Date: Thu, 15 Jul 2021 17:49:27 -0700 Subject: [PATCH] Added notice for when the nidaqmx drivers are not detected --- beskar/popups.py | 18 +++++++++++++++--- beskar/utils.py | 10 ++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/beskar/popups.py b/beskar/popups.py index bd11e67..9f6947e 100644 --- a/beskar/popups.py +++ b/beskar/popups.py @@ -75,7 +75,15 @@ def __init__(self, main_window): self.label = QtWidgets.QLabel( "SEAL kit not detected, please make sure it's plugged in" ) - self.label.setObjectName('label') + + self.no_drivers = QtWidgets.QLabel( + 'WARNING: Drivers are not detected on this computer. ' + 'In order to connect with the SEAL kit you must install the drivers from ' + 'here.' + ) + self.no_drivers.setOpenExternalLinks(True) + self.no_drivers.setWordWrap(True) + self.no_drivers.hide() self.combo_box = QtWidgets.QComboBox() self.combo_box.setObjectName('combo_box') @@ -96,11 +104,12 @@ def __init__(self, main_window): self.main_layout = QtWidgets.QVBoxLayout() self.main_layout.addWidget(self.label) + self.main_layout.addWidget(self.no_drivers) self.main_layout.addLayout(self.buttons_layout) self.setWindowFlag(QtCore.Qt.WindowType.WindowCloseButtonHint, on=False) - self.setFixedSize(311, 68) + self.setFixedSize(315, 68) @QtCore.pyqtSlot() def on_refresh_push_button_clicked(self): @@ -109,7 +118,10 @@ def on_refresh_push_button_clicked(self): for _ in range(5): QtTest.QTest.qWait(100) self.label.setText(f"{self.label.text()}.") - system, num_of_devices = get_number_of_devices() + system, num_of_devices, has_drivers = get_number_of_devices(drivers=True) + if not has_drivers and self.no_drivers.isHidden(): + self.setFixedHeight(130) + self.no_drivers.show() if num_of_devices == 0: self.label.setText('SEAL kit not detected, please try refreshing again.') else: diff --git a/beskar/utils.py b/beskar/utils.py index 476b147..9c9c56d 100644 --- a/beskar/utils.py +++ b/beskar/utils.py @@ -49,8 +49,9 @@ def interact_with_LEDs(device_name: str, interaction: Literal['on', 'off', 'on&o task.write(False) task.write(True) -def get_number_of_devices(system=True): +def get_number_of_devices(system=True, drivers=False): errors = (FileNotFoundError, DaqNotFoundError) + has_drivers = True try: from __main__ import PyInstallerImportError errors += (PyInstallerImportError,) @@ -61,8 +62,13 @@ def get_number_of_devices(system=True): num_of_devices = len(the_system.devices) except errors: num_of_devices = 0 - if system: + has_drivers = False + if system and drivers: + return the_system, num_of_devices, has_drivers + elif system: return the_system, num_of_devices + elif drivers: + return the_system, has_drivers else: return num_of_devices