Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
jborbely committed Mar 29, 2020
2 parents 25c9817 + 40d2e70 commit 209c763
Show file tree
Hide file tree
Showing 24 changed files with 875 additions and 56 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 - 2019, Measurement Standards Laboratory of New Zealand
Copyright (c) 2017 - 2020, Measurement Standards Laboratory of New Zealand

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
7 changes: 7 additions & 0 deletions docs/_api/msl.qt.constants.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
msl.qt.constants module
=======================

.. automodule:: msl.qt.constants
:members:
:undoc-members:
:show-inheritance:
2 changes: 2 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ which has the following modules

.. autosummary::

msl.qt.constants
msl.qt.exceptions
msl.qt.io
msl.qt.prompt
Expand Down Expand Up @@ -45,6 +46,7 @@ Package Structure
:maxdepth: 1

msl.qt <_api/msl.qt>
msl.qt.constants <_api/msl.qt.constants>
msl.qt.exceptions <_api/msl.qt.exceptions>
msl.qt.io <_api/msl.qt.io>
msl.qt.loop_until_abort <_api/msl.qt.loop_until_abort>
Expand Down
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ def __getattr__(cls, name):
# 'PyQt5': ('', 'pyqt5-modified-objects.inv'),
# 'PySide2': ('https://doc.qt.io/qtforpython/', None),
'PySide2': ('', 'pyside2-modified-objects.inv'),
'msl.equipment': ('https://msl-equipment.readthedocs.io/en/latest/', None),
}

# show all the Qt linking warnings
Expand Down
5 changes: 4 additions & 1 deletion msl/examples/qt/button.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
"""
A :class:`~msl.qt.widget.button.Button` example.
"""
from msl.qt import application, Button
from msl.qt import (
application,
Button
)


def left():
Expand Down
5 changes: 4 additions & 1 deletion msl/examples/qt/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import random
import logging

from msl.qt import application, Logger
from msl.qt import (
application,
Logger
)


def show():
Expand Down
5 changes: 4 additions & 1 deletion msl/examples/qt/loop_until_abort.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"""
import tempfile

from msl.qt import prompt, LoopUntilAbort
from msl.qt import (
prompt,
LoopUntilAbort
)


class LoopExample(LoopUntilAbort):
Expand Down
5 changes: 4 additions & 1 deletion msl/examples/qt/loop_until_abort_sleep.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"""
import random

from msl.qt import LoopUntilAbort, Sleep
from msl.qt import (
LoopUntilAbort,
Sleep
)


class LoopExampleSleep(LoopUntilAbort):
Expand Down
7 changes: 6 additions & 1 deletion msl/examples/qt/show_standard_icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
Display all the icons available in :obj:`QtWidgets.QStyle.StandardPixmap` and in
the *standard* Windows DLL/EXE files.
"""
from msl.qt import QtWidgets, QtCore, application, io
from msl.qt import (
QtWidgets,
QtCore,
application,
io
)

try:
# check if pythonnet is installed
Expand Down
6 changes: 5 additions & 1 deletion msl/examples/qt/toggle_switch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"""
Example showing the :class:`~msl.qt.widgets.toggle_switch.ToggleSwitch`.
"""
from msl.qt import QtWidgets, application, ToggleSwitch
from msl.qt import (
QtWidgets,
application,
ToggleSwitch
)


def print_state(checked):
Expand Down
5 changes: 4 additions & 1 deletion msl/qt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ def application(*args):
from .loop_until_abort import LoopUntilAbort
from . import prompt
from .sleep import Sleep
from .threading import Thread, Worker
from .threading import (
Thread,
Worker,
)
from .widgets import (
Button,
Logger,
Expand Down
8 changes: 8 additions & 0 deletions msl/qt/_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@
if not building_docs and not (has_pyside or has_pyqt):
raise ImportError('Either PySide2 or PyQt5 must be installed')

if building_docs and not has_pyside and not has_pyqt:
raise ImportError(
'To build the docs you must either install PySide2 or PyQt5.\n'
'Alternatively, you can temporarily enable mocking in conf.py using\n'
' if on_rtd or True:\n'
'WARNING!!! do not commit this temporary change to the conf.py file'
)

if use_pyside:
from PySide2 import QtGui
from PySide2 import QtCore
Expand Down
69 changes: 68 additions & 1 deletion msl/qt/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,73 @@
Constants used by the **MSL-Qt** package.
"""
import os
from enum import Enum

HOME_DIR = os.path.join(os.path.expanduser('~'), '.msl')
""":class:`str`: The default ``$HOME`` directory where all files are to be located."""
""":class:`str`: The default ``$HOME`` directory where all files used by **MSL-Qt** are located."""

SI_PREFIX_MAP = {i: prefix for i, prefix in enumerate('yzafpn\u00b5m kMGTPEZY', start=-8)}
""":class:`dict`: The SI prefixes used to form multiples of 10**(3*n), n=-8..8"""


class GREEK(Enum):
"""Greek letters."""
Alpha = '\u0391'
Beta = '\u0392'
Gamma = '\u0393'
Delta = '\u0394'
Epsilon = '\u0395'
Zeta = '\u0396'
Eta = '\u0397'
Theta = '\u0398'
Iota = '\u0399'
Kappa = '\u039A'
Lambda = '\u039B'
Mu = '\u039C'
Nu = '\u039D'
Xi = '\u039E'
Omicron = '\u039F'
Pi = '\u03A0'
Rho = '\u03A1'
Sigma = '\u03A3'
Tau = '\u03A4'
Upsilon = '\u03A5'
Phi = '\u03A6'
Chi = '\u03A7'
Psi = '\u03A8'
Omega = '\u03A9'
alpha = '\u03B1'
beta = '\u03B2'
gamma = '\u03B3'
delta = '\u03B4'
epsilon = '\u03B5'
zeta = '\u03B6'
eta = '\u03B7'
theta = '\u03B8'
iota = '\u03B9'
kappa = '\u03BA'
lambda_ = '\u03BB'
mu = '\u03BC'
nu = '\u03BD'
xi = '\u03BE'
omicron = '\u03BF'
pi = '\u03C0'
rho = '\u03C1'
sigmaf = '\u03C2'
sigma = '\u03C3'
tau = '\u03C4'
upsilon = '\u03C5'
phi = '\u03C6'
chi = '\u03C7'
psi = '\u03C8'
omega = '\u03C9'
thetasym = '\u03D1'
upsih = '\u03D2'
straightphi = '\u03D5'
piv = '\u03D6'
Gammad = '\u03DC'
gammad = '\u03DD'
varkappa = '\u03F0'
varrho = '\u03F1'
straightepsilon = '\u03F5'
backepsilon = '\u03F6'
4 changes: 1 addition & 3 deletions msl/qt/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
Exception handling.
"""
import logging
import traceback as tb

from .utils import logger
from . import (
Qt,
QtGui,
Expand All @@ -12,8 +12,6 @@
prompt,
)

logger = logging.getLogger(__name__)


def excepthook(exctype, value, traceback):
"""Displays unhandled exceptions in a :class:`QtWidgets.QMessageBox`.
Expand Down
8 changes: 7 additions & 1 deletion msl/qt/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
import sys
import fnmatch

from . import QtWidgets, QtGui, QtCore, Qt, application
from . import (
QtWidgets,
QtGui,
QtCore,
Qt,
application
)

__all__ = (
'get_drag_enter_paths',
Expand Down
8 changes: 7 additions & 1 deletion msl/qt/loop_until_abort.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
import datetime
import traceback

from . import QtWidgets, QtCore, QtGui, application, prompt
from . import (
QtWidgets,
QtCore,
QtGui,
application,
prompt
)


class LoopUntilAbort(object):
Expand Down
5 changes: 4 additions & 1 deletion msl/qt/sleep.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"""
import time

from .threading import Thread, Worker
from .threading import (
Thread,
Worker
)


class SleepWorker(Worker):
Expand Down
9 changes: 5 additions & 4 deletions msl/qt/threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
Base classes for starting a process in a new :class:`QThread`.
"""
import sys
import logging
import traceback as tb

from . import QtCore, Signal, prompt

logger = logging.getLogger(__name__)
from . import (
QtCore,
Signal,
prompt
)


class Worker(QtCore.QObject):
Expand Down

0 comments on commit 209c763

Please sign in to comment.