Skip to content

Commit

Permalink
pyside6 and UI Designer (and About dialog as example) (#770)
Browse files Browse the repository at this point in the history
* chore: migrate to pyside6
* feat: add platform and host cpu to the runtime info
* fix: fix window icon loading
  • Loading branch information
redrathnure authored Jan 26, 2025
1 parent 80e20df commit 9ca8d0f
Show file tree
Hide file tree
Showing 80 changed files with 977 additions and 332 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ NanoVNASaver.spec


*.spec
*_rc.py
2 changes: 1 addition & 1 deletion build-macos-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pip install PyInstaller==6.11.0

python3 setup.py -V

pyinstaller --onedir -p src -n NanoVNASaver nanovna-saver.py --recursive-copy-metadata NanoVNASaver --window --clean -y -i icon_48x48.icns --add-data "icon_48x48.png:." --recursive-copy-metadata NanoVNASaver
pyinstaller --onedir -p src -n NanoVNASaver src/NanoVNASaver/__main__.py --recursive-copy-metadata NanoVNASaver --window --clean -y -i icon_48x48.icns --recursive-copy-metadata NanoVNASaver
tar -C dist -zcf ./dist/NanoVNASaver.app-`uname -m`.tar.gz NanoVNASaver.app

deactivate
Expand Down
12 changes: 12 additions & 0 deletions docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ A few usefull commands:
* 🚧 TODO: - update dependencies ignoring in `pyproject.toml` specified version constraints.
* `uv lock` - update dependency lock file respecting specified version constraints.

## UI Development

UI layout of Widget, Dialogs and Window stored in `*.ui` files and may be edited by QT Designer. Please use `uv run pyside6-designer` or `uv run task ui-designer` to launch QT Designer. Please note

* UI layout should be creatd and stored via UI files
* fields name should follow python_snake_style_naming scheme
* elements should have meaningful names and initial values
* elements which are not going to be changed during runtime should have `_` prefix
* Icons, images and other resources should be stored as part of `main.qrc` file.
* compiled resource files (e.g. `main_rc.py`) should not be put under git version control
* ui and resource files may be compiled manually via `uv run task compile` or will be executed automatically during `uv build` phase.

## Build Process

### Python packages
Expand Down
37 changes: 0 additions & 37 deletions nanovna-saver.py

This file was deleted.

30 changes: 16 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ dynamic=['version']

dependencies=[
'pyserial~=3.5',
'PyQt6~=6.8',
'PyQt6-sip~=13.8',
'pyside6~=6.8',
'numpy~=2.1',
'scipy~=1.14',
]
Expand Down Expand Up @@ -73,16 +72,20 @@ requires = [
"setuptools>=64",
"setuptools-scm>=8"
]
build-backend = 'setuptools.build_meta'

# build-backend = 'setuptools.build_meta'
# in-tree build backend, wrapper around setuptools, just to run ui-compile task
# See also https://setuptools.pypa.io/en/latest/build_meta.html#dynamic-build-dependencies-and-other-build-meta-tweaks
build-backend = "setuptools_wrapper"
backend-path = ["src/tools"]

[tool.setuptools.exclude-package-data]
"*" = ['*.png', '*.ui', '*.qrc' ]

[tool.setuptools.packages.find]
# See https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html for more details
where = ["src"]



[tool.setuptools_scm]
# For smarter version schemes and other configuration options,
# check out https://github.com/pypa/setuptools_scm
Expand All @@ -96,16 +99,15 @@ test = "pytest ."
test-cov = "pytest --cov=src ."
test-full = "tox"

clean = "task clean_dist & task clean_build & task clean_py & task clean_logs & task clean_pycache"
clean_dist = "rm -r dist"
clean_build = "rm -r build"
clean_py = "python -Bc \"import pathlib; [p.unlink() for p in pathlib.Path('.').rglob('*.py[co]')]\""
clean_logs = "python -Bc \"import pathlib; [p.unlink() for p in pathlib.Path('.').rglob('*.log')]\""
clean_pycache = " python -Bc \"import pathlib; [p.rmdir() for p in pathlib.Path('.').rglob('__pycache__')]\""
clean = "python -m tools.project_clean"

ui-compile = "python -m tools.ui_compile"
ui-designer = "pyside6-designer"


build-pkg-win = "pyinstaller --onefile -p src -n nanovna-saver.exe nanovna-saver.py --recursive-copy-metadata NanoVNASaver --noconsole -i icon_48x48.ico --add-data \"icon_48x48.png:.\""
build-pkg-linux = "pyinstaller --onefile -p src -n nanovna-saver nanovna-saver.py --recursive-copy-metadata NanoVNASaver --add-data \"icon_48x48.png:.\""
build-pkg-macos = "pyinstaller --onedir -p src -n NanoVNASaver nanovna-saver.py --recursive-copy-metadata NanoVNASaver --window --clean -y -i icon_48x48.icns --add-data \"icon_48x48.png:.\" && tar -C dist -zcf ./dist/NanoVNASaver.app-`uname -m`.tar.gz NanoVNASaver.app"
build-pkg-win = "pyinstaller --onefile -p src -n nanovna-saver.exe src/NanoVNASaver/__main__.py --recursive-copy-metadata NanoVNASaver --noconsole -i icon_48x48.ico"
build-pkg-linux = "pyinstaller --onefile -p src -n nanovna-saver src/NanoVNASaver/__main__.py --recursive-copy-metadata NanoVNASaver"
build-pkg-macos = "pyinstaller --onedir -p src -n NanoVNASaver src/NanoVNASaver/__main__.py --recursive-copy-metadata NanoVNASaver --window --clean -y -i icon_48x48.icns && tar -C dist -zcf ./dist/NanoVNASaver.app-`uname -m`.tar.gz NanoVNASaver.app"



Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Analysis/AntennaAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import logging
from time import sleep

from PyQt6 import QtWidgets
from PySide6 import QtWidgets

from NanoVNASaver.Analysis.VSWRAnalysis import VSWRAnalysis

Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Analysis/BandPassAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import logging
import math

from PyQt6 import QtWidgets
from PySide6 import QtWidgets

import NanoVNASaver.AnalyticTools as At
from NanoVNASaver.Analysis.Base import CUTOFF_VALS, MIN_CUTOFF_DAMPING, Analysis
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Analysis/Base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import logging
from typing import TYPE_CHECKING

from PyQt6 import QtWidgets
from PySide6 import QtWidgets

if TYPE_CHECKING:
from NanoVNASaver.NanoVNASaver import NanoVNASaver as NanoVNA
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Analysis/EFHWAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import csv
import logging

from PyQt6 import QtWidgets
from PySide6 import QtWidgets

import NanoVNASaver.AnalyticTools as At
from NanoVNASaver.Analysis.ResonanceAnalysis import (
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Analysis/HighPassAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import logging
import math

from PyQt6 import QtWidgets
from PySide6 import QtWidgets

import NanoVNASaver.AnalyticTools as At
from NanoVNASaver.Analysis.Base import CUTOFF_VALS, MIN_CUTOFF_DAMPING, Analysis
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Analysis/PeakSearchAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import logging

import numpy as np
from PyQt6 import QtWidgets
from PySide6 import QtWidgets

# pylint: disable=import-error, no-name-in-module
from scipy.signal import find_peaks, peak_prominences
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Analysis/ResonanceAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import logging
import os

from PyQt6 import QtWidgets
from PySide6 import QtWidgets

import NanoVNASaver.AnalyticTools as At
from NanoVNASaver.Analysis.Base import Analysis, QHLine
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Analysis/SimplePeakSearchAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from typing import Callable

import numpy as np
from PyQt6 import QtWidgets
from PySide6 import QtWidgets

from NanoVNASaver.Analysis.Base import Analysis, QHLine
from NanoVNASaver.Formatting import (
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Analysis/VSWRAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import logging
from typing import TYPE_CHECKING

from PyQt6 import QtWidgets
from PySide6 import QtWidgets

import NanoVNASaver.AnalyticTools as At
from NanoVNASaver.Analysis.Base import Analysis, QHLine
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Charts/CLogMag.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import logging
import math

from PyQt6 import QtGui
from PySide6 import QtGui

from NanoVNASaver.Charts.Chart import Chart
from NanoVNASaver.Charts.LogMag import LogMagChart
Expand Down
8 changes: 4 additions & 4 deletions src/NanoVNASaver/Charts/Chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
from dataclasses import dataclass, field, replace
from typing import Any, ClassVar, NamedTuple

from PyQt6 import QtCore, QtGui, QtWidgets
from PyQt6.QtCore import Qt, pyqtSignal
from PyQt6.QtGui import QAction, QColor, QColorConstants
from PySide6 import QtCore, QtGui, QtWidgets
from PySide6.QtCore import Qt, Signal
from PySide6.QtGui import QAction, QColor, QColorConstants

from NanoVNASaver import Defaults
from NanoVNASaver.Marker.Widget import Marker
Expand Down Expand Up @@ -115,7 +115,7 @@ def draw(self, x: int, y: int, color: QtGui.QColor, text: str = ""):

class Chart(QtWidgets.QWidget):
bands: ClassVar[Any] = None
popout_requested: ClassVar[pyqtSignal] = pyqtSignal(object)
popout_requested: ClassVar[Signal] = Signal(object)
color: ClassVar[ChartColors] = ChartColors()

def __init__(self, name) -> None:
Expand Down
4 changes: 2 additions & 2 deletions src/NanoVNASaver/Charts/Frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import math

import numpy as np
from PyQt6 import QtCore, QtGui, QtWidgets
from PyQt6.QtCore import Qt
from PySide6 import QtCore, QtGui, QtWidgets
from PySide6.QtCore import Qt

from NanoVNASaver.Charts.Chart import Chart
from NanoVNASaver.Formatting import (
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Charts/GroupDelay.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import math

import numpy as np
from PyQt6 import QtGui
from PySide6 import QtGui

from NanoVNASaver.Charts.Chart import Chart
from NanoVNASaver.RFTools import Datapoint
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Charts/LogMag.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import math
from dataclasses import dataclass

from PyQt6 import QtGui
from PySide6 import QtGui

from NanoVNASaver.Charts.Chart import Chart
from NanoVNASaver.Charts.Frequency import FrequencyChart
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Charts/Magnitude.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import logging
import math

from PyQt6 import QtGui
from PySide6 import QtGui

from NanoVNASaver.Charts.Chart import Chart
from NanoVNASaver.Charts.Frequency import FrequencyChart
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Charts/MagnitudeZ.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import logging
import math

from PyQt6 import QtGui
from PySide6 import QtGui

from NanoVNASaver.Charts.Chart import Chart
from NanoVNASaver.Charts.Frequency import FrequencyChart
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Charts/Permeability.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import logging
import math

from PyQt6 import QtGui
from PySide6 import QtGui

from NanoVNASaver.Charts.Chart import Chart
from NanoVNASaver.Charts.Frequency import FrequencyChart
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Charts/Phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import math

import numpy as np
from PyQt6.QtGui import QAction, QPainter, QPen
from PySide6.QtGui import QAction, QPainter, QPen

from NanoVNASaver.Charts.Chart import Chart
from NanoVNASaver.Charts.Frequency import FrequencyChart
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Charts/Polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import logging

from PyQt6 import QtCore, QtGui
from PySide6 import QtCore, QtGui

from NanoVNASaver.Charts.Chart import Chart
from NanoVNASaver.Charts.Square import SquareChart
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Charts/QFactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import logging
import math

from PyQt6 import QtGui
from PySide6 import QtGui

from NanoVNASaver.Charts.Chart import Chart
from NanoVNASaver.Charts.Frequency import FrequencyChart
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Charts/RI.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import logging
import math

from PyQt6 import QtGui, QtWidgets
from PySide6 import QtGui, QtWidgets

from NanoVNASaver.Charts.Chart import Chart, ChartPosition
from NanoVNASaver.Charts.Frequency import FrequencyChart
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Charts/RIMu.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import math

import numpy as np
from PyQt6 import QtGui, QtWidgets
from PySide6 import QtGui, QtWidgets
from scipy.constants import mu_0

from NanoVNASaver.Charts.Chart import Chart
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Charts/RIZ.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import logging

from PyQt6 import QtGui
from PySide6 import QtGui

from NanoVNASaver.Charts.Chart import Chart
from NanoVNASaver.Formatting import format_frequency_chart
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Charts/SParam.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import logging

from PyQt6 import QtGui
from PySide6 import QtGui

from NanoVNASaver.Charts.Chart import Chart
from NanoVNASaver.Charts.Frequency import FrequencyChart
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Charts/Smith.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import logging

from PyQt6 import QtCore, QtGui
from PySide6 import QtCore, QtGui

from NanoVNASaver.Charts.Chart import Chart
from NanoVNASaver.Charts.Square import SquareChart
Expand Down
2 changes: 1 addition & 1 deletion src/NanoVNASaver/Charts/Square.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import logging
import math

from PyQt6 import QtCore, QtGui, QtWidgets
from PySide6 import QtCore, QtGui, QtWidgets

from NanoVNASaver.Charts.Chart import Chart
from NanoVNASaver.RFTools import Datapoint
Expand Down
6 changes: 3 additions & 3 deletions src/NanoVNASaver/Charts/TDR.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import math

import numpy as np
from PyQt6.QtCore import QPoint, QRect, Qt
from PyQt6.QtGui import (
from PySide6.QtCore import QPoint, QRect, Qt
from PySide6.QtGui import (
QAction,
QActionGroup,
QMouseEvent,
Expand All @@ -31,7 +31,7 @@
QPen,
QResizeEvent,
)
from PyQt6.QtWidgets import QInputDialog, QMenu, QSizePolicy
from PySide6.QtWidgets import QInputDialog, QMenu, QSizePolicy

from NanoVNASaver.Charts.Chart import Chart

Expand Down
Loading

0 comments on commit 9ca8d0f

Please sign in to comment.