From 4136ff68cf0137fb6adaa0d59c6df3b746be3ed2 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sun, 10 Jan 2016 18:18:47 +0800 Subject: [PATCH] gui/applets/simple: support for optional datasets --- artiq/applets/simple.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/artiq/applets/simple.py b/artiq/applets/simple.py index 94ba27c00..f11f58ca3 100644 --- a/artiq/applets/simple.py +++ b/artiq/applets/simple.py @@ -30,11 +30,14 @@ class SimpleApplet: help="embed main widget into existing window") self._arggroup_datasets = self.argparser.add_argument_group("datasets") - def add_dataset(self, name, help=None): - if help is None: - self._arggroup_datasets.add_argument(name) + def add_dataset(self, name, help=None, required=True): + kwargs = dict() + if help is not None: + kwargs["help"] = help + if required: + self._arggroup_datasets.add_argument(name, **kwargs) else: - self._arggroup_datasets.add_argument(name, help=help) + self._arggroup_datasets.add_argument("--" + name, **kwargs) def args_init(self): self.args = self.argparser.parse_args()