From 084c39b137f620366321fb676a85721abcc5a763 Mon Sep 17 00:00:00 2001 From: hanjinliu Date: Tue, 17 Aug 2021 22:55:25 +0900 Subject: [PATCH] docs and prettier import --- docs/_build/html | 2 +- impy/viewer/keybinds.py | 13 +++++++------ impy/viewer/widgets/dialog.py | 9 +++++++-- impy/viewer/widgets/explorer.py | 8 ++++++-- impy/viewer/widgets/textedit.py | 5 +++++ 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/docs/_build/html b/docs/_build/html index 66c981da..7041b9c3 160000 --- a/docs/_build/html +++ b/docs/_build/html @@ -1 +1 @@ -Subproject commit 66c981dae2d4c874e2897b60cf1f8cb4c3f04f4b +Subproject commit 7041b9c394d596e4a6f0c7608e4f364532129960 diff --git a/impy/viewer/keybinds.py b/impy/viewer/keybinds.py index cf5a0fe3..09baf82e 100644 --- a/impy/viewer/keybinds.py +++ b/impy/viewer/keybinds.py @@ -1,12 +1,13 @@ -from impy.viewer.widgets.dialog import ProjectionDialog -from ..arrays import LabeledArray -from ..core import array as ip_array -from .utils import * -from .widgets import DuplicateDialog import numpy as np from napari.layers.utils._link_layers import link_layers, unlink_layers import napari +from .utils import * +from .widgets import DuplicateDialog, ProjectionDialog + +from ..arrays import LabeledArray +from ..core import array as ip_array + # Shift, Control, Alt, Meta, Up, Down, Left, Right, PageUp, PageDown, Insert, # Delete, Home, End, Escape, Backspace, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, # F11, F12, Space, Enter, Tab @@ -336,7 +337,7 @@ def proj(viewer:"napari.Viewer"): @bind_key def duplicate_layer(viewer:"napari.Viewer"): """ - Duplicate selected layer(s). + Duplicate the selected layer. """ layer = get_a_selected_layer(viewer) diff --git a/impy/viewer/widgets/dialog.py b/impy/viewer/widgets/dialog.py index 634a90ef..c59ef197 100644 --- a/impy/viewer/widgets/dialog.py +++ b/impy/viewer/widgets/dialog.py @@ -1,6 +1,4 @@ from __future__ import annotations -from impy.utils.axesop import find_first_appeared -from PyQt5.QtWidgets import QVBoxLayout from qtpy.QtWidgets import QDialog, QPushButton, QLabel, QGridLayout, QCheckBox, QLineEdit, QComboBox, QHBoxLayout import napari import numpy as np @@ -9,6 +7,7 @@ from ..utils import add_labeledarray, copy_layer, front_image, add_labels from ..._const import SetConst from ...utils.slicer import axis_targeted_slicing +from ...utils.axesop import find_first_appeared def close_anyway(func): @wraps(func) @@ -85,6 +84,9 @@ def _add_widgets(self): class DuplicateDialog(QDialog): + """ + This dialog is opened when an image layer is duplicated. + """ def __init__(self, viewer:"napari.Viewer", layer): self.viewer = viewer self.layer = layer @@ -169,6 +171,9 @@ def _add_widgets(self): return None class ProjectionDialog(QDialog): + """ + This dialog is opened when an image layer is projected. + """ def __init__(self, viewer:"napari.Viewer", layer): self.viewer = viewer self.layer = layer diff --git a/impy/viewer/widgets/explorer.py b/impy/viewer/widgets/explorer.py index eb2a7d1d..b56a92b5 100644 --- a/impy/viewer/widgets/explorer.py +++ b/impy/viewer/widgets/explorer.py @@ -15,6 +15,10 @@ from ...core import imread class Explorer(QWidget): + """ + A Read-only explorer widget. Capable of filter, set working directory, copy path and open file in the viewer. + By default QTreeView supports real time update on file change. + """ def __init__(self, viewer:"napari.Viewer", path:str=""): super().__init__(viewer.window._qt_window) self.viewer = viewer @@ -92,7 +96,7 @@ def __init__(self, parent, path:str): self.show() - def _set_file_model(self, path): + def _set_file_model(self, path:str): self.file_system.setRootPath(path) self.setModel(self.file_system) self.setRootIndex(self.file_system.index(path)) @@ -173,7 +177,7 @@ def keyPressEvent(self, event): return super().keyPressEvent(event) @property - def selected(self): + def selected(self) -> QModelIndex: inds = self.selectionModel().selectedIndexes() if len(inds) > 0: index = inds[0] diff --git a/impy/viewer/widgets/textedit.py b/impy/viewer/widgets/textedit.py index 568b756e..09f49d31 100644 --- a/impy/viewer/widgets/textedit.py +++ b/impy/viewer/widgets/textedit.py @@ -16,6 +16,9 @@ def read_txt(viewer:"napari.Viewer", path:str): return viewer.window.add_dock_widget(text, area="right", name=title) class TxtFileWidget(QWidget): + """ + A read-only text viewer widget with JSON-like highlight. Capable of search lines. + """ def __init__(self, viewer:"napari.Viewer", title:str=None): super().__init__(viewer.window._qt_window) self.viewer = viewer @@ -103,6 +106,8 @@ def _(): self.layout().addWidget(wid) def change_wrap_mode(self): + # line wrap mode = 0 -> No wrap + # line wrap mode = 1 -> wrapped mode = self.txtviewer.lineWrapMode() self.txtviewer.setLineWrapMode(1-mode) return None