Skip to content

Commit

Permalink
Adding Qt Event processing as wait routine in GUI + typing
Browse files Browse the repository at this point in the history
  • Loading branch information
mmouchous-ledger committed Jan 9, 2024
1 parent f6e4e8c commit 746e9b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions pystages/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
QCheckBox,
QLineEdit,
)
from PyQt6.QtCore import QObject, QTimer, QLocale
from PyQt6.QtCore import QObject, QTimer, QLocale, QCoreApplication
from PyQt6.QtGui import QDoubleValidator
from ..cncrouter import CNCRouter
from ..corvus import Corvus
Expand All @@ -20,7 +20,6 @@
from enum import Enum
from serial.tools.list_ports import comports
from serial.tools.list_ports_common import ListPortInfo
from ..vector import Vector


class StageType(str, Enum):
Expand Down Expand Up @@ -60,6 +59,9 @@ def connect(self, on_off):

self.set_controls_enabled(on_off)

if self.stage is not None:
self.stage.wait_routine = lambda: QCoreApplication.processEvents()

def __init__(self):
super().__init__()

Expand Down
4 changes: 2 additions & 2 deletions pystages/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Copyright 2018-2022 Ledger SAS, written by Michaël Mouchous

from .vector import Vector
from typing import Optional
from typing import Optional, Callable
from abc import ABC, abstractmethod
from serial.tools.list_ports import comports

Expand All @@ -36,7 +36,7 @@ def __init__(self, num_axis=1):
self.num_axis = num_axis
# The wait routine is a function that is called when the wait_move_finished is looping.
# It can be used to add some temporization and/or UI updates.
self.wait_routine = None
self.wait_routine: Optional[Callable] = None

# Minimum and maximum software limits
self._minimums: Optional[Vector] = None
Expand Down

0 comments on commit 746e9b6

Please sign in to comment.