diff --git a/nixview/communicator.py b/nixview/communicator.py index 1cd553f..5d4d084 100644 --- a/nixview/communicator.py +++ b/nixview/communicator.py @@ -1,14 +1,16 @@ from nixview.data_models.tree_model import NixTreeItem from PyQt5.QtCore import QObject, pyqtSignal + class Communicate(QObject): """ Small class for across app communication. Defines signals, to which other classes can connect. """ open_recent = pyqtSignal(str) - + item_selected = pyqtSignal(NixTreeItem) - + plot_error = pyqtSignal(str) - -communicator = Communicate() \ No newline at end of file + + +communicator = Communicate() diff --git a/nixview/constants.py b/nixview/constants.py index 6fa1d54..35647ec 100644 --- a/nixview/constants.py +++ b/nixview/constants.py @@ -7,7 +7,7 @@ application = "nixview" version = 0.1 settings_recent_files_key = "/".join([organization, application, "recent_files"]) -settings_recent_file_max_count_key = "/".join([organization, application, "recent_files_max_count"]) +settings_recent_file_max_count_key = "/".join([organization, application, "recent_files_max_count"]) settings_recent_file_max_count = 10 max_chunksize = 1000000000 @@ -20,12 +20,13 @@ ICONS_PATHS = glob.glob(os.path.join(ICONS_FOLDER, "*.png")) ICONS_PATHS.extend(glob.glob(os.path.join(ICONS_FOLDER, "*.icns"))) ICONS_PATHS = sorted(ICONS_PATHS) ICON_DICT = {} + for icon in ICONS_PATHS: ICON_DICT[icon.split(os.sep)[-1].split(".")[0]] = icon + def get_icon(name): if name in ICON_DICT.keys(): return QIcon(ICON_DICT[name]) else: return QIcon("nix_logo.png") - diff --git a/nixview/nixview.py b/nixview/nixview.py index cc4bd3a..c7e86ce 100755 --- a/nixview/nixview.py +++ b/nixview/nixview.py @@ -4,6 +4,7 @@ from PyQt5.QtWidgets import QApplication from nixview.ui.mainwindow import NixView import argparse + def main(): parser = argparse.ArgumentParser(description="NixView. Viewer for NIX data files. For more on nix see https://nixio.readthedocs.io/en/master") parser.add_argument("file", nargs="?", default="", type=str, help="The nix file that should be opened.") @@ -17,5 +18,6 @@ def main(): window.show() sys.exit(app.exec_()) + if __name__ == "__main__": main() diff --git a/nixview/util/descriptors.py b/nixview/util/descriptors.py index 2262f5f..c5f7045 100644 --- a/nixview/util/descriptors.py +++ b/nixview/util/descriptors.py @@ -1,13 +1,16 @@ import os import datetime as dt + class ItemDescriptor(): - def __init__(self, name=None, id=None, type=None, value=None, unit=None, label=None, definition=None, block_id=None, entity_type=None, shape=None, metadata=None, data_type=None, source_id=None, created_at=None, updated_at=None) -> None: + def __init__(self, name=None, id=None, type=None, value=None, unit=None, label=None, + definition=None, block_id=None, entity_type=None, shape=None, metadata=None, + data_type=None, source_id=None, created_at=None, updated_at=None) -> None: super().__init__() self.name = name self.type = type self.id = id - self.block_id= block_id + self.block_id = block_id self.definition = definition self.value = value self.unit = unit @@ -22,7 +25,6 @@ class ItemDescriptor(): self.best_xdim = None self.suggested_plotter = None - def to_html(self): descr = "

%s: %s

" % (self.type, self.name) descr += "
    " @@ -39,10 +41,10 @@ class ItemDescriptor(): descr += "
  1. created at: %s
  2. " % (str(dt.datetime.fromtimestamp(self.created_at)) if self.created_at else "") descr += "
  3. updated at: %s
  4. " % (str(dt.datetime.fromtimestamp(self.updated_at)) if self.updated_at else "") descr += "
" - + descr += "" return descr - + def __str__(self) -> str: return "Entity: %s, id: %s, type: %s " % (self.name, self.id, self.entity_type) @@ -62,7 +64,7 @@ class FileDescriptor(): self.tag_count = 0 self.group_count = 0 self.data_frame_count = 0 - + def toHtml(self): def namAndPath(filename): parts = filename.split(os.sep) @@ -92,4 +94,3 @@ class FileDescriptor(): descr += "" descr += "" return descr - diff --git a/nixview/util/enums.py b/nixview/util/enums.py index 2f0cc45..179b2d6 100644 --- a/nixview/util/enums.py +++ b/nixview/util/enums.py @@ -13,7 +13,7 @@ class NodeType(Enum): Tag = "Tag" MultiTag = "Multi Tag" Group = "Group" - Feature="Feature" + Feature = "Feature" class TreeType(Enum): @@ -28,4 +28,3 @@ class PlotterTypes(Enum): CategoryPlotter = "category" EventPlotter = "event" Undecided = "undecided" - diff --git a/nixview_main.py b/nixview_main.py index 3069ff1..ca6a6a8 100644 --- a/nixview_main.py +++ b/nixview_main.py @@ -2,4 +2,4 @@ from nixview.nixview import main if __name__ == "__main__": - main() \ No newline at end of file + main()