Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
Add ui file path to base main window
Browse files Browse the repository at this point in the history
  • Loading branch information
BenediktBurger committed Feb 12, 2024
1 parent 6ccec96 commit aef29e3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
8 changes: 6 additions & 2 deletions pyleco_extras/gui/data_logger/data/data_logger_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
from pyleco.utils.pipe_handler import PipeHandler
from pyleco.utils.events import Event
from pyleco.utils.listener import Listener
from pyleco.utils.qt_listener import QtListener
try:
from pyleco.utils.qt_listener import ListenerSignals
except ImportError:
from pyleco.utils.qt_listener import QtListener
ListenerSignals = QtListener.ListenerSignals # type: ignore


class Signals(QtListener.ListenerSignals):
class Signals(ListenerSignals):
"""Signals for the DataLogger message handler."""
started = Signal()
configuration_changed = Signal(dict)
Expand Down
5 changes: 4 additions & 1 deletion pyleco_extras/gui/data_logger/data_logger_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

# Standard packages.
import logging
from pathlib import Path
import time
from typing import Any, Iterable, Optional

Expand Down Expand Up @@ -57,7 +58,9 @@ class DataLoggerBase(LECOBaseMainWindowDesigner):

def __init__(self, name: str, **kwargs) -> None:
# Use initialization of parent class QMainWindow.
super().__init__(name=name, ui_file_name="DataLogger", **kwargs)
super().__init__(name=name, ui_file_name="DataLogger",
ui_file_path=Path(__file__).parent / "data",
**kwargs)

# Load the user interface file, and configure the dock area and show it.
self.dockArea = DockArea()
Expand Down
2 changes: 1 addition & 1 deletion pyleco_extras/gui/data_logger/data_logger_viewer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Remotely control a DataLogger
View data files of a DataLogger
Created on Thu Apr 1 15:14:39 2021 by Benedikt Burger
"""
Expand Down
18 changes: 14 additions & 4 deletions pyleco_extras/gui_utils/base_main_window.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

import logging
from typing import Optional
from pathlib import Path
from typing import Optional, Union

from qtpy import QtCore, QtGui, QtWidgets, uic
from qtpy.QtCore import Slot # type: ignore
Expand Down Expand Up @@ -117,18 +118,27 @@ def show_namespace_information(self, full_name: str):


class LECOBaseMainWindowDesigner(_LECOBaseMainWindow):
"""Base MainWindow subclass with a LECO listener, UI defined via designer ui file."""
"""Base MainWindow subclass with a LECO listener, UI defined via designer ui file.
:param name: Leco name
:param ui_file_name: Name of the ui_file (without ".ui" termination)
:param ui_file_path: Path to the ui file. Relative "data" or absolute, e.g.
`pathlib.Path(__file__).parent / "data"`.
"""

def __init__(self,
name: str,
ui_file_name: str,
ui_file_path: Union[Path, str] = "data",
settings_dialog_class: type[QtWidgets.QDialog] | None = None,
host: str = "localhost",
port: int = COORDINATOR_PORT,
logger: logging.Logger = log,
data_port: int = PROXY_SENDING_PORT,
**kwargs) -> None:
self._ui_file_name = ui_file_name
if isinstance(ui_file_path, str):
ui_file_path = Path(ui_file_path)
self._file_path = ui_file_path / f"{ui_file_name}.ui"
super().__init__(name=name,
settings_dialog_class=settings_dialog_class,
host=host,
Expand All @@ -138,7 +148,7 @@ def __init__(self,
**kwargs)

def _setup_ui(self):
uic.load_ui.loadUi(f"data/{self._ui_file_name}.ui", self)
uic.load_ui.loadUi(self._file_path, self)


class LECOBaseMainWindowNoDesigner(_LECOBaseMainWindow):
Expand Down

0 comments on commit aef29e3

Please sign in to comment.