Skip to content

Commit

Permalink
tooltip and bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hanjinliu committed Aug 17, 2021
1 parent 7a07c9a commit 220ef3b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
22 changes: 18 additions & 4 deletions impy/viewer/widgets/explorer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations
from qtpy.QtWidgets import (QWidget, QFileSystemModel, QTreeView, QMenu, QAction, QGridLayout, QLineEdit, QPushButton,
QFileDialog)
QFileDialog, QHBoxLayout, QLabel)
from qtpy.QtCore import Qt, QModelIndex
import os
import napari
Expand Down Expand Up @@ -46,13 +46,25 @@ def _add_filetree(self, path:str):
return None

def _add_filter_line(self):
self.line = QLineEdit(self)
wid = QWidget(self)
wid.setLayout(QHBoxLayout())

# add label
label = QLabel(self)
label.setText("Filter file name: ")

self.line = QLineEdit(self)
self.line.setToolTip("Filter by names split by comma. e.g. '*.tif, *csv'.")

@self.line.editingFinished.connect
def _():
self.tree.set_filter(self.line.text())

self.layout().addWidget(self.line)


wid.layout().addWidget(label)
wid.layout().addWidget(self.line)

self.layout().addWidget(wid)

class FileTree(QTreeView):
def __init__(self, parent, path:str):
Expand Down Expand Up @@ -143,6 +155,8 @@ def onDoubleClicked(self, index:QModelIndex):

def set_filter(self, names:str|list[str]):
if isinstance(names, str):
if names == "":
names = "*"
names = names.split(",")
names = [s.strip() for s in names]
self.file_system.setNameFilters(names)
Expand Down
2 changes: 1 addition & 1 deletion impy/viewer/widgets/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ def __init__(self, viewer:"napari.Viewer", df:np.ndarray|pd.DataFrame|dict, colu
self._add_edit_menu()
self._add_plot_menu()

self.setCentralWidget(self.table_native)
self.setUnifiedTitleAndToolBarOnMac(True)
self.setWindowTitle(self.name)
self.setCentralWidget(self.table_native)


def __repr__(self):
Expand Down
6 changes: 4 additions & 2 deletions impy/viewer/widgets/textedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ def _add_filter_line(self):

# add label
label = QLabel(self)
label.setText("Filter:")
label.setText("Search:")

# add line edit
self.line = QLineEdit(self)
self.line = QLineEdit(self)
self.line.setToolTip("Search line by line with words or regular expressions.")
@self.line.editingFinished.connect
def _():
text = self.line.text()
Expand All @@ -93,6 +94,7 @@ def _():
# add check box
self.checkbox = QCheckBox(self)
self.checkbox.setText("Regex")
self.checkbox.setToolTip("Use regular expression.")

wid.layout().addWidget(label)
wid.layout().addWidget(self.line)
Expand Down

0 comments on commit 220ef3b

Please sign in to comment.