Browse Source

added optional GUI script

master
Holger Frey 5 years ago
parent
commit
73de76565b
  1. 8
      pyproject.toml
  2. 16
      sartorius_logger/__init__.py
  3. 19
      sartorius_logger/parsers.py

8
pyproject.toml

@ -37,6 +37,14 @@ test = [
dev = [ dev = [
"keyring", "keyring",
] ]
gui = [
"Gooey >= 1.0.3",
"pyinstaller >= 3.5"
]
[tool.flit.scripts]
loggercli = "sartorius_logger:cli"
SartoriusLogger = "sartorius_logger:gui"
[tool.black] [tool.black]
line-length = 79 line-length = 79

16
sartorius_logger/__init__.py

@ -16,6 +16,13 @@ from tqdm import tqdm
from .datalogger import DataLogger, NullLogger from .datalogger import DataLogger, NullLogger
from .parsers import parse_cli_arguments from .parsers import parse_cli_arguments
try:
from gooey import Gooey
except ImportError as exc:
def Gooey(*args, **kargs):
msg = "The graphilcal user interface must be installed separately"
raise NotImplementedError(msg)
SCALE_INFO_LABELS = { SCALE_INFO_LABELS = {
sartoriusb.CMD_INFO_TYPE: "Scale Model", sartoriusb.CMD_INFO_TYPE: "Scale Model",
@ -173,3 +180,12 @@ def cli():
settings, progress_bar=tqdm, data_logger=DataLogger(log_file_path) settings, progress_bar=tqdm, data_logger=DataLogger(log_file_path)
) )
export_as_excel(result) export_as_excel(result)
@Gooey(program_name="SartoriusLogger")
def gui():
settings = parse_cli_arguments()
log_file_path = _get_log_file_path(settings)
result = measure_series(
settings, progress_bar=tqdm, data_logger=DataLogger(log_file_path)
)
export_as_excel(result)

19
sartorius_logger/parsers.py

@ -52,6 +52,25 @@ def parse_cli_arguments():
return _normalize_cli_arguments(raw_arguments) return _normalize_cli_arguments(raw_arguments)
def parse_gui_arguments():
from gooey import GooeyParser
""" parses command line interface arguments """
parser = argparse.GooeyParser(
description="Make time series measurements with a Sartorius scale.",
epilog=(
"Times can be specified as 10s, 10m, or 10h"
"for seconds, minutes or hours respectively."
"A relative directory path starts at the Desktop."
),
)
parser.add_argument("port", nargs="?", default="COM4", metavar="COMPORT", help="Serial Port that connects the Scale, defaults to 'COM4'")
parser.add_argument("-d", "--duration", nargs="?", default="30m", help="Measurement duration, e.g. 10s, 30m, 2h")
parser.add_argument("-i", "--interval", nargs="?", default="10s", help="Measurement interval, e.g. 5s, 1m, 1h")
parser.add_argument("-o", "--output", nargs="?", metavar="DIRECTORY", widget='DirChooser', help="Select Output Directory, defaults to 'Desktop'")
raw_arguments = parser.parse_args()
return _normalize_cli_arguments(raw_arguments)
# helper functions # helper functions

Loading…
Cancel
Save