New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add delete button for layers #65
Conversation
Hello @sofroniewn! Thanks for updating the PR.
Comment last updated on November 20, 2018 at 05:45 Hours UTC |
One extra thing to note, is that occasionally (though reproducibly) I get a warning message when deleting layers. One way to see it is to run the first 6 cells of the WARNING: Traceback (most recent call last):
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/ipykernel_launcher.py", line 16, in <module>
app.launch_new_instance()
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance
app.start()
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/ipykernel/kernelapp.py", line 499, in start
self.io_loop.start()
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/tornado/platform/asyncio.py", line 132, in start
self.asyncio_loop.run_forever()
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/asyncio/base_events.py", line 422, in run_forever
self._run_once()
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/asyncio/base_events.py", line 1432, in _run_once
handle._run()
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/asyncio/events.py", line 145, in _run
self._callback(*self._args)
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/tornado/ioloop.py", line 758, in _run_callback
ret = callback()
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/tornado/stack_context.py", line 300, in null_wrapper
return fn(*args, **kwargs)
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 295, in advance_eventloop
eventloop(self)
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/ipykernel/eventloops.py", line 137, in loop_qt5
return loop_qt4(kernel)
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/ipykernel/eventloops.py", line 130, in loop_qt4
_loop_qt(kernel.app)
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/ipykernel/eventloops.py", line 114, in _loop_qt
app.exec_()
File "/Users/nicholassofroniew/Github/napari-gui/napari_gui/elements/qt/_layerPanel.py", line 40, in on_click
self.layers.remove_selected()
File "/Users/nicholassofroniew/Github/napari-gui/napari_gui/elements/_layer_list.py", line 333, in remove_selected
self.pop(i)
File "/Users/nicholassofroniew/Github/napari-gui/napari_gui/elements/_layer_list.py", line 199, in pop
self.events.remove_item(item=item)
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/vispy/util/event.py", line 455, in __call__
self._invoke_callback(cb, event)
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/vispy/util/event.py", line 471, in _invoke_callback
cb(event)
File "/Users/nicholassofroniew/Github/napari-gui/napari_gui/elements/_layer_list.py", line 310, in _remove
layer.viewer = None
File "/Users/nicholassofroniew/Github/napari-gui/napari_gui/layers/_base_layer.py", line 96, in viewer
self._parent = parent
File "/Users/nicholassofroniew/Github/napari-gui/napari_gui/layers/_visual_wrapper.py", line 44, in _parent
self._node.parent = parent
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/vispy/util/frozen.py", line 17, in __setattr__
object.__setattr__(self, key, value)
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/vispy/scene/node.py", line 209, in parent
self._update_trsys(None)
File "/Users/nicholassofroniew/Github/napari-gui/napari_gui/_vispy/scene/visuals.py", line 82, in _update_trsys
self.transforms.scene_transform = scene.node_transform(doc)
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/vispy/visuals/transforms/transform_system.py", line 276, in scene_transform
self._scene_transform.transforms = tr
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/vispy/visuals/transforms/chain.py", line 96, in transforms
self.update()
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/vispy/visuals/transforms/base_transform.py", line 153, in update
self.changed(*args)
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/vispy/util/event.py", line 455, in __call__
self._invoke_callback(cb, event)
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/vispy/util/event.py", line 471, in _invoke_callback
cb(event)
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/vispy/visuals/transforms/chain.py", line 212, in _subtr_changed
self.update(ev)
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/vispy/visuals/transforms/base_transform.py", line 153, in update
self.changed(*args)
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/vispy/util/event.py", line 455, in __call__
self._invoke_callback(cb, event)
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/vispy/util/event.py", line 475, in _invoke_callback
self, cb_event=(cb, event))
<< caught exception here: >>
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/vispy/util/event.py", line 471, in _invoke_callback
cb(event)
File "/Users/nicholassofroniew/anaconda3/lib/python3.6/site-packages/vispy/visuals/transforms/chain.py", line 281, in source_changed
new_tr = [tr[0]]
IndexError: list index out of range
ERROR: Invoking <bound method SimplifiedChainTransform.source_changed of <ChainTransform [<STTransform scale=[1. 1. 1. 1.] translate=[0. 0. 0. 0.] at 0x4961768952>,
<STTransform scale=[1.0227273e+00 1.0227273e+00 1.0000000e-06 1.0000000e+00] translate=[138.18182 26.181818 0. 0. ] at 0x4941059856>] at 0x126ca7da0>> for Event |
@sofroniewn that traceback looks pretty nasty, and I imagine it's a bug in vispy since you are not doing anything too fancy here... Although maybe this is weakref biting us in the butt? ;) What do people think about having a trashcan icon on the layers themselves? |
My initial impulse was to have the trashicon on every button, but then I moved away from it as similar applications with layers have a single trash button, but I remain open to the possibility. I can try deleting the weakref call and seeing if I get the same error |
The independent trashcan icon seems most intuitive to me, but I would like to note that while other applications typically modify their layers in-place, we will typically be creating a new layer every time. In that scenario, perhaps making the deletion of individual layers as easy as possible should be a priority. |
I have just created a new PR #68 that adds more properties to layers, and any discussion of including a trashIcon on a layer or not should probably look at what changes are being proposed there |
The changes in this PR are also included in #68 along with some additional ones. In order to simplify things I will close this PR in favor of the other one |
# Description Adding right-click controls, main menu options and other copy edits to napari viewer tutorial. ## Type of change - [x] Fixes or improves existing content # References None ## Final checklist: - [x] My PR is the minimum possible work for the desired functionality - [x] I have added [alt text](https://webaim.org/techniques/alttext/) to new images included in this PR --------- Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com> Co-authored-by: Melissa Weber Mendonça <melissawm@gmail.com>
What does this PR do? Why are doing this? References?
This PR adds a delete button above the layer list. Clicking the button will deleted the selected layers if there are any. Alternatively dragging and dropping onto the delete button will delete the dragged layers along with any others that are selected if the dragged layer is also selected.
Right now the deleting happens automatically. In the future we could add dialog box seeking confirmation before a delete that could be disabled in preferences.
One thing to note also is that if you delete all the layers and then try and add a new one you get an error. This behavior is true even if deleting layers directly from the notebook and should be fixed in some future PR.
One final note is that this PR also contains the drag and drop changes in PR #64 which have not been merged yet. The first 8 commits are in that PR and it should probably be merged first and then this one can be merged with only the changes relevant to the delete button.
Type of change
[Please delete options that are not relevant.]
How Has This Been Tested?
Final Checklist: