diff --git a/flake.nix b/flake.nix index 824bf39..9056fa9 100644 --- a/flake.nix +++ b/flake.nix @@ -62,7 +62,7 @@ format = "pyproject"; src = pkgs.fetchPypi { inherit pname version; - sha256 = "sha256-jcdo/R7l3hBEx8MF7M8tOdJNh4A+pxGJ1AJPtHX0mF8="; + hash = "sha256-jcdo/R7l3hBEx8MF7M8tOdJNh4A+pxGJ1AJPtHX0mF8="; }; buildInputs = [ pkgs.python3Packages.poetry-core ]; propagatedBuildInputs = [ pkgs.python3Packages.pyqt6 ]; @@ -74,7 +74,7 @@ format = "pyproject"; src = pkgs.fetchPypi { inherit pname version; - sha256 = "sha256-WBCNhBHHBU4IQdi3ke6F4QH8KWubNZwOAd3jipj/Ks4="; + hash = "sha256-WBCNhBHHBU4IQdi3ke6F4QH8KWubNZwOAd3jipj/Ks4="; }; propagatedBuildInputs = with pkgs.python3Packages; [ numpy pyqt6 ]; }; @@ -85,7 +85,7 @@ format = "pyproject"; src = pkgs.fetchPypi { inherit pname version; - sha256 = "sha256-jqj8X6H1N5mJQ4OrY5ANqRB0YJByqg/bNneEALWmH1A="; + hash = "sha256-jqj8X6H1N5mJQ4OrY5ANqRB0YJByqg/bNneEALWmH1A="; }; buildInputs = [ pkgs.python3Packages.poetry-core ]; propagatedBuildInputs = [ pyqtgraph pkgs.python3Packages.numpy ]; diff --git a/pytec/MANIFEST.in b/pytec/MANIFEST.in new file mode 100644 index 0000000..5be0b39 --- /dev/null +++ b/pytec/MANIFEST.in @@ -0,0 +1,4 @@ +graft examples +include pytec/gui/resources/artiq.ico +include pytec/gui/view/param_tree.json +include pytec/gui/view/tec_qt.ui diff --git a/pytec/aioexample.py b/pytec/examples/aioexample.py similarity index 100% rename from pytec/aioexample.py rename to pytec/examples/aioexample.py diff --git a/pytec/example.py b/pytec/examples/example.py similarity index 100% rename from pytec/example.py rename to pytec/examples/example.py diff --git a/pytec/pyproject.toml b/pytec/pyproject.toml index 73ce527..4af3992 100644 --- a/pytec/pyproject.toml +++ b/pytec/pyproject.toml @@ -15,7 +15,4 @@ tec_qt = "tec_qt:main" [tool.setuptools] packages.find = {} -py-modules = ["aioexample", "autotune", "example", "plot", "tec_qt", "ui_tec_qt", "waitingspinnerwidget"] - -[tool.setuptools.package-data] -"*" = ["*.*"] +py-modules = ["autotune", "plot", "tec_qt"] diff --git a/pytec/model/pid_autotuner.py b/pytec/pytec/gui/model/pid_autotuner.py similarity index 100% rename from pytec/model/pid_autotuner.py rename to pytec/pytec/gui/model/pid_autotuner.py diff --git a/pytec/model/property.py b/pytec/pytec/gui/model/property.py similarity index 100% rename from pytec/model/property.py rename to pytec/pytec/gui/model/property.py diff --git a/pytec/model/thermostat_data_model.py b/pytec/pytec/gui/model/thermostat.py similarity index 97% rename from pytec/model/thermostat_data_model.py rename to pytec/pytec/gui/model/thermostat.py index d1a47aa..4f2c195 100644 --- a/pytec/model/thermostat_data_model.py +++ b/pytec/pytec/gui/model/thermostat.py @@ -1,7 +1,7 @@ from pytec.aioclient import Client from PyQt6.QtCore import pyqtSignal, QObject, pyqtSlot from qasync import asyncSlot -from model.property import Property, PropertyMeta +from pytec.gui.model.property import Property, PropertyMeta import asyncio import logging @@ -104,7 +104,7 @@ class Thermostat(QObject, metaclass=PropertyMeta): self.report[i]["interval"] for i in range(len(self.report)) ] - async def disconnect(self): + async def end_session(self): await self._client.end_session() async def set_ipv4(self, ipv4): diff --git a/pytec/resources/artiq.ico b/pytec/pytec/gui/resources/artiq.ico similarity index 100% rename from pytec/resources/artiq.ico rename to pytec/pytec/gui/resources/artiq.ico diff --git a/pytec/view/conn_menu.py b/pytec/pytec/gui/view/conn_menu.py similarity index 98% rename from pytec/view/conn_menu.py rename to pytec/pytec/gui/view/conn_menu.py index 80da10c..89c9896 100644 --- a/pytec/view/conn_menu.py +++ b/pytec/pytec/gui/view/conn_menu.py @@ -1,7 +1,7 @@ from PyQt6 import QtWidgets, QtCore -class conn_menu(QtWidgets.QMenu): +class ConnMenu(QtWidgets.QMenu): def __init__(self): super().__init__() self.setTitle("Connection Settings") diff --git a/pytec/view/ctrl_panel.py b/pytec/pytec/gui/view/ctrl_panel.py similarity index 99% rename from pytec/view/ctrl_panel.py rename to pytec/pytec/gui/view/ctrl_panel.py index 9ad5a99..0c8d9d2 100644 --- a/pytec/view/ctrl_panel.py +++ b/pytec/pytec/gui/view/ctrl_panel.py @@ -42,7 +42,7 @@ class MutexParameter(pTypes.ListParameter): registerParameterType("mutex", MutexParameter) -class ctrl_panel(QObject): +class CtrlPanel(QObject): set_zero_limits_warning_sig = pyqtSignal(list) def __init__( diff --git a/pytec/view/info_box.py b/pytec/pytec/gui/view/info_box.py similarity index 89% rename from pytec/view/info_box.py rename to pytec/pytec/gui/view/info_box.py index 3d5c491..cde0591 100644 --- a/pytec/view/info_box.py +++ b/pytec/pytec/gui/view/info_box.py @@ -2,7 +2,7 @@ from PyQt6 import QtWidgets from PyQt6.QtCore import pyqtSlot -class info_box(QtWidgets.QMessageBox): +class InfoBox(QtWidgets.QMessageBox): def __init__(self): super().__init__() self.setIcon(QtWidgets.QMessageBox.Icon.Information) diff --git a/pytec/view/live_plot_view.py b/pytec/pytec/gui/view/live_plot_view.py similarity index 97% rename from pytec/view/live_plot_view.py rename to pytec/pytec/gui/view/live_plot_view.py index e9ea57a..a4771fd 100644 --- a/pytec/view/live_plot_view.py +++ b/pytec/pytec/gui/view/live_plot_view.py @@ -66,9 +66,10 @@ class _TecGraphs: self._t_line = self._t_widget.getPlotItem().addLine(label="{value} °C") self._t_line.setVisible(False) + # Hack for keeping setpoint line in plot range self._t_setpoint_plot = ( LiveLinePlot() - ) # Hack for keeping setpoint line in plot range + ) for graph in t_widget, i_widget: time_axis = LiveAxis( @@ -83,8 +84,8 @@ class _TecGraphs: # Enable linking of axes in the graph widget's context menu graph.register( - graph.getPlotItem().titleLabel.text - ) # Slight hack getting the title + graph.getPlotItem().titleLabel.text # Slight hack getting the title + ) temperature_axis = LiveAxis("left", text="Temperature", units="°C") temperature_axis.showLabel() diff --git a/pytec/view/net_settings_input_diag.py b/pytec/pytec/gui/view/net_settings_input_diag.py similarity index 95% rename from pytec/view/net_settings_input_diag.py rename to pytec/pytec/gui/view/net_settings_input_diag.py index fb1c242..1ef4f61 100644 --- a/pytec/view/net_settings_input_diag.py +++ b/pytec/pytec/gui/view/net_settings_input_diag.py @@ -3,7 +3,7 @@ from PyQt6.QtWidgets import QAbstractButton from PyQt6.QtCore import pyqtSignal, pyqtSlot -class net_settings_input_diag(QtWidgets.QInputDialog): +class NetSettingsInputDiag(QtWidgets.QInputDialog): set_ipv4_act = pyqtSignal(str) def __init__(self, current_ipv4_settings): diff --git a/pytec/view/param_tree.json b/pytec/pytec/gui/view/param_tree.json similarity index 100% rename from pytec/view/param_tree.json rename to pytec/pytec/gui/view/param_tree.json diff --git a/pytec/view/plot_options_menu.py b/pytec/pytec/gui/view/plot_options_menu.py similarity index 93% rename from pytec/view/plot_options_menu.py rename to pytec/pytec/gui/view/plot_options_menu.py index 427684a..7817d58 100644 --- a/pytec/view/plot_options_menu.py +++ b/pytec/pytec/gui/view/plot_options_menu.py @@ -1,7 +1,7 @@ from PyQt6 import QtWidgets, QtGui -class plot_options_menu(QtWidgets.QMenu): +class PlotOptionsMenu(QtWidgets.QMenu): def __init__(self, max_samples=1000): super().__init__() self.setTitle("Plot Settings") diff --git a/pytec/view/tec_qt.ui b/pytec/pytec/gui/view/tec_qt.ui similarity index 99% rename from pytec/view/tec_qt.ui rename to pytec/pytec/gui/view/tec_qt.ui index c7d8b35..8b20fd9 100644 --- a/pytec/view/tec_qt.ui +++ b/pytec/pytec/gui/view/tec_qt.ui @@ -588,7 +588,7 @@ QtWaitingSpinner QWidget -
view.waitingspinnerwidget
+
pytec.gui.view.waitingspinnerwidget
1
diff --git a/pytec/view/thermostat_ctrl_menu.py b/pytec/pytec/gui/view/thermostat_ctrl_menu.py similarity index 99% rename from pytec/view/thermostat_ctrl_menu.py rename to pytec/pytec/gui/view/thermostat_ctrl_menu.py index e22dfba..2ef321b 100644 --- a/pytec/view/thermostat_ctrl_menu.py +++ b/pytec/pytec/gui/view/thermostat_ctrl_menu.py @@ -2,7 +2,7 @@ from PyQt6 import QtWidgets, QtGui, QtCore from PyQt6.QtCore import pyqtSignal, pyqtSlot -class thermostat_ctrl_menu(QtWidgets.QMenu): +class ThermostatCtrlMenu(QtWidgets.QMenu): fan_set_act = pyqtSignal(int) fan_auto_set_act = pyqtSignal(int) diff --git a/pytec/view/waitingspinnerwidget.py b/pytec/pytec/gui/view/waitingspinnerwidget.py similarity index 100% rename from pytec/view/waitingspinnerwidget.py rename to pytec/pytec/gui/view/waitingspinnerwidget.py diff --git a/pytec/view/zero_limits_warning.py b/pytec/pytec/gui/view/zero_limits_warning.py similarity index 97% rename from pytec/view/zero_limits_warning.py rename to pytec/pytec/gui/view/zero_limits_warning.py index 574e04d..113aef0 100644 --- a/pytec/view/zero_limits_warning.py +++ b/pytec/pytec/gui/view/zero_limits_warning.py @@ -2,7 +2,7 @@ from PyQt6.QtCore import pyqtSlot, QObject from PyQt6 import QtWidgets, QtGui -class zero_limits_warning_view(QObject): +class ZeroLimitsWarningView(QObject): def __init__(self, style, limit_warning): super().__init__() self._lbl = limit_warning diff --git a/pytec/setup.py b/pytec/setup.py index 4ac8f58..7e3828f 100644 --- a/pytec/setup.py +++ b/pytec/setup.py @@ -14,5 +14,5 @@ setup( "tec_qt = tec_qt:main", ] }, - py_modules=['tec_qt', 'ui_tec_qt', 'autotune', 'waitingspinnerwidget'], + py_modules=['autotune', 'plot', 'tec_qt'], ) diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 4acd26d..e2d5312 100644 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -1,13 +1,13 @@ -from view.zero_limits_warning import zero_limits_warning_view -from view.net_settings_input_diag import net_settings_input_diag -from view.thermostat_ctrl_menu import thermostat_ctrl_menu -from view.conn_menu import conn_menu -from view.plot_options_menu import plot_options_menu -from view.live_plot_view import LiveDataPlotter -from view.ctrl_panel import ctrl_panel -from view.info_box import info_box -from model.pid_autotuner import PIDAutoTuner -from model.thermostat_data_model import WrappedClient, Thermostat +from pytec.gui.view.zero_limits_warning import ZeroLimitsWarningView +from pytec.gui.view.net_settings_input_diag import NetSettingsInputDiag +from pytec.gui.view.thermostat_ctrl_menu import ThermostatCtrlMenu +from pytec.gui.view.conn_menu import ConnMenu +from pytec.gui.view.plot_options_menu import PlotOptionsMenu +from pytec.gui.view.live_plot_view import LiveDataPlotter +from pytec.gui.view.ctrl_panel import CtrlPanel +from pytec.gui.view.info_box import InfoBox +from pytec.gui.model.pid_autotuner import PIDAutoTuner +from pytec.gui.model.thermostat import WrappedClient, Thermostat import json from autotune import PIDAutotuneState from qasync import asyncSlot, asyncClose @@ -23,9 +23,6 @@ from functools import partial import importlib.resources -pg.setConfigOptions(antialias=True) - - def get_argparser(): parser = argparse.ArgumentParser(description="Thermostat Control Panel") @@ -47,7 +44,7 @@ def get_argparser(): parser.add_argument( "-p", "--param_tree", - default=importlib.resources.files("view").joinpath("param_tree.json"), + default=importlib.resources.files("pytec.gui.view").joinpath("param_tree.json"), help="Param Tree Description JSON File", ) @@ -60,13 +57,11 @@ class MainWindow(QtWidgets.QMainWindow): def __init__(self, args): super(MainWindow, self).__init__() - ui_file_path = importlib.resources.files("view").joinpath("tec_qt.ui") + ui_file_path = importlib.resources.files("pytec.gui.view").joinpath("tec_qt.ui") uic.loadUi(ui_file_path, self) - self.show() - self.hw_rev_data = None - self.info_box = info_box() + self.info_box = InfoBox() self.client = WrappedClient(self) self.client.connection_error.connect(self.bail) @@ -94,10 +89,10 @@ class MainWindow(QtWidgets.QMainWindow): ] self.thermostat.info_box_trigger.connect(self.info_box.display_info_box) - self.zero_limits_warning = zero_limits_warning_view( + self.zero_limits_warning = ZeroLimitsWarningView( self.style(), self.limits_warning ) - self.ctrl_panel_view = ctrl_panel( + self.ctrl_panel_view = CtrlPanel( [self.ch0_tree, self.ch1_tree], get_ctrl_panel_config(args), self.send_command, @@ -136,17 +131,17 @@ class MainWindow(QtWidgets.QMainWindow): self.thermostat.report_update.connect(self.channel_graphs.update_report) self.thermostat.pid_update.connect(self.channel_graphs.update_pid) - self.plot_options_menu = plot_options_menu() + self.plot_options_menu = PlotOptionsMenu() self.plot_options_menu.clear.triggered.connect(self.clear_graphs) self.plot_options_menu.samples_spinbox.valueChanged.connect( self.channel_graphs.set_max_samples ) self.plot_settings.setMenu(self.plot_options_menu) - self.conn_menu = conn_menu() + self.conn_menu = ConnMenu() self.connect_btn.setMenu(self.conn_menu) - self.thermostat_ctrl_menu = thermostat_ctrl_menu(self.style()) + self.thermostat_ctrl_menu = ThermostatCtrlMenu(self.style()) self.thermostat_ctrl_menu.fan_set_act.connect(self.fan_set_request) self.thermostat_ctrl_menu.fan_auto_set_act.connect(self.fan_auto_set_request) self.thermostat_ctrl_menu.reset_act.connect(self.reset_request) @@ -213,8 +208,8 @@ class MainWindow(QtWidgets.QMainWindow): return with QSignalBlocker(self.thermostat_ctrl_menu.fan_power_slider): self.thermostat_ctrl_menu.fan_power_slider.setValue( - fan_settings["fan_pwm"] or 100 - ) # 0 = PWM off = full strength + fan_settings["fan_pwm"] or 100 # 0 = PWM off = full strength + ) with QSignalBlocker(self.thermostat_ctrl_menu.fan_auto_box): self.thermostat_ctrl_menu.fan_auto_box.setChecked(fan_settings["auto_mode"]) if not self.hw_rev_data["settings"]["fan_pwm_recommended"]: @@ -399,7 +394,7 @@ class MainWindow(QtWidgets.QMainWindow): @asyncSlot(bool) async def net_settings_request(self, _): ipv4 = await self.thermostat.get_ipv4() - self.net_settings_input_diag = net_settings_input_diag(ipv4["addr"]) + self.net_settings_input_diag = NetSettingsInputDiag(ipv4["addr"]) self.net_settings_input_diag.set_ipv4_act.connect(self.set_net_settings_request) @asyncSlot(str) @@ -419,7 +414,7 @@ async def coro_main(): app = QtWidgets.QApplication.instance() app.aboutToQuit.connect(app_quit_event.set) app.setWindowIcon( - QtGui.QIcon(str(importlib.resources.files("resources").joinpath("artiq.ico"))) + QtGui.QIcon(str(importlib.resources.files("pytec.gui.resources").joinpath("artiq.ico"))) ) main_window = MainWindow(args)