Skip to content

Commit

Permalink
add HOST_IP to config variables
Browse files Browse the repository at this point in the history
  • Loading branch information
mscheltienne committed Oct 30, 2024
1 parent 69680e4 commit af58b7d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
17 changes: 8 additions & 9 deletions eyelink_track/_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ class GUI(QMainWindow):
Parameters
----------
host_ip : str | None
IP Address of the computer hosting the eye-tracking device.
If None, a dummy eye-tracker is created.
mock : bool
If True, uses a mock eye-tracker.
"""

def __init__(self, host_ip: str | None = "100.1.1.1") -> None:
if host_ip is not None:
check_type(host_ip, (str,), "host_ip")
self._host_ip = host_ip
def __init__(self, mock: bool) -> None:
check_type(mock, (bool,), "mock")
self._mock = mock
super().__init__()
self.setCentralWidget(CentralWidget())
# tool bar
Expand Down Expand Up @@ -85,8 +83,9 @@ def start(self) -> None:
screen = self.centralWidget().findChildren(QComboBoxScreen)[0].screen
resolution = self.centralWidget().findChildren(QComboBoxScreen)[0].resolution
# start eye-tracker
self.eye_link = Eyelink(directory, fname, self._host_ip, screen, resolution)
if self._host_ip is not None:
kwargs = dict(host_ip=None) if self._mock else dict()
self.eye_link = Eyelink(directory, fname, screen, resolution, **kwargs)
if not self._mock:
self.statusBar().showMessage("[Calibrating..]")
self.eye_link.calibrate()
self.eye_link.win.close()
Expand Down
3 changes: 1 addition & 2 deletions eyelink_track/commands/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ def run(mock: bool) -> None:
from .._gui import GUI

app = QApplication([])
kwargs = dict(host_ip=None) if mock else dict()
window = GUI(**kwargs) # noqa: F841
window = GUI(mock) # noqa: F841
app.exec()
1 change: 1 addition & 0 deletions eyelink_track/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@

# Eye-tracker constants
FOREGROUND_COLOR = (0, 0, 0)
HOST_IP: str = "100.1.1.1"
4 changes: 2 additions & 2 deletions eyelink_track/eye_link/EyeLink.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from psychopy.event import waitKeys
from psychopy.visual import TextStim, Window

from ..config import FOREGROUND_COLOR, SCREEN_KWARGS
from ..config import FOREGROUND_COLOR, HOST_IP, SCREEN_KWARGS
from ..utils._checks import check_type, ensure_int, ensure_path
from ..utils.logs import logger
from .EyeLinkCoreGraphicsPsychoPy import EyeLinkCoreGraphicsPsychoPy
Expand Down Expand Up @@ -44,7 +44,7 @@ def __init__(
self,
pname: str | Path = "./",
fname: str = "TEST",
host_ip: str | None = "100.1.1.1",
host_ip: str | None = HOST_IP,
screen: int | None = None,
resolution: tuple[int, int] | None = None,
) -> None:
Expand Down

0 comments on commit af58b7d

Please sign in to comment.