added command line arguments; made adding the example data optional

This commit is contained in:
2023-01-13 16:00:05 +01:00
parent c09b6e5d0d
commit 2ace45fd6c
2 changed files with 19 additions and 3 deletions

View File

@ -1,3 +1,4 @@
import argparse
import sys
from PyQt5.QtWidgets import QApplication
@ -10,9 +11,22 @@ def main():
app = QApplication(sys.argv)
theme.apply(app)
ctrl_c.setup(app)
mw = MainWindow()
clargs = handle_clargs()
mw = MainWindow(**clargs)
mw.show()
sys.exit(app.exec())
def handle_clargs():
DESC = "grum - GUI for Remote Unified Monitoring"
parser = argparse.ArgumentParser(description=DESC, formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("-H", "--host", default="localhost", help="Server host name")
parser.add_argument("-P", "--port", default=8000, type=int, help="Server port number")
parser.add_argument("-e", "--examples", dest="add_examples", action="store_true", help="Add example data")
return parser.parse_args().__dict__

View File

@ -15,16 +15,18 @@ class MainWindow(QMainWindow):
sig_make_new_plot = pyqtSignal(str, PlotDescription)
def __init__(self, *args, title="grum", host="localhost", port=8000, **kwargs):
def __init__(self, *args, title="grum", host="localhost", port=8000, add_examples=False, **kwargs):
super().__init__(*args, **kwargs)
self.setWindowTitle(title)
self.setWindowIcon(assets.icon())
self.lst = lst = DictList()
lst.update(exampledata)
lst.setAlternatingRowColors(True)
lst.itemDoubleClicked.connect(self.on_dclick_list_item)
if add_examples:
lst.update(exampledata)
lst_menu = lst.lst.menu
lst_menu.addSeparator()
lst_menu.addAction("Plot selected", self.on_plot_selected)