Skip to content

Commit 8648b15

Browse files
committed
MAINT: Simplify Viewers class
1 parent a3a11b1 commit 8648b15

File tree

1 file changed

+6
-29
lines changed

1 file changed

+6
-29
lines changed

itkwidgets/cell_watcher.py

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,18 @@ def data(self):
1919
@property
2020
def not_created(self):
2121
# Return a list of names of viewers that have not been created yet
22-
names = []
23-
for key, val in self.data.items():
24-
name = val['name']
25-
if not val['status']:
26-
name = name if name is not None else key
27-
names.append(name)
28-
return names
22+
return [k for k in self.data.keys() if not self.viewer_ready(k)]
2923

30-
@property
31-
def not_named(self):
32-
# Return a list of names of viewers that have not been named yet
33-
return any([k for k, v in self.data.items() if v['name'] is None])
34-
35-
@property
36-
def viewer_objects(self):
37-
# Return a list of created viewers
38-
return list(self.data.keys())
39-
40-
def add_viewer(self, view):
41-
self.data[view] = {'name': None, 'status': False}
42-
43-
def set_name(self, view, name):
44-
if view not in self.data.keys():
45-
self.add_viewer(view)
46-
self.data[view]['name'] = name
24+
def add_viewer(self, view: str) -> None:
25+
self.data[view] = {"ready": False}
4726

4827
def update_viewer_status(self, view, status):
4928
if view not in self.data.keys():
5029
self.add_viewer(view)
51-
self.data[view]['status'] = status
30+
self.data[view]["ready"] = status
5231

53-
def viewer_ready(self, view):
54-
if viewer := self.data.get(view):
55-
return viewer['status']
56-
return False
32+
def viewer_ready(self, view: str) -> bool:
33+
return self.data.get(view, {}).get("ready", False)
5734

5835

5936
class CellWatcher(object):

0 commit comments

Comments
 (0)