tk-rt-viewer 2.3.3__tar.gz → 2.3.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/.github/workflows/ci.yml +3 -0
  2. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/CHANGELOG.md +34 -0
  3. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/PKG-INFO +23 -5
  4. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/README.md +22 -4
  5. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/__init__.py +1 -1
  6. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/event_controllers/viewer_events.py +84 -2
  7. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/rendering/view_axes.py +31 -5
  8. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/viewer.py +31 -2
  9. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/tests/test_event_controllers.py +187 -3
  10. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/.gitattributes +0 -0
  11. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/.gitignore +0 -0
  12. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/LICENSE +0 -0
  13. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/pyproject.toml +0 -0
  14. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/event_controllers/__init__.py +0 -0
  15. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/event_controllers/bbox3d_handler.py +0 -0
  16. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/event_controllers/bbox_handler.py +0 -0
  17. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/event_controllers/brush_handler.py +0 -0
  18. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/event_controllers/crosshair_handler.py +0 -0
  19. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/event_controllers/rect_drag.py +0 -0
  20. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/events.py +0 -0
  21. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/geometry.py +0 -0
  22. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/io.py +0 -0
  23. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/isodose_levels.py +0 -0
  24. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/protocols.py +0 -0
  25. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/py.typed +0 -0
  26. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/reg_io.py +0 -0
  27. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/registration/__init__.py +0 -0
  28. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/registration/deformable.py +0 -0
  29. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/registration/errors.py +0 -0
  30. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/registration/params.py +0 -0
  31. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/registration/rigid.py +0 -0
  32. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/registration/session.py +0 -0
  33. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/registration/template.py +0 -0
  34. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/rendering/__init__.py +0 -0
  35. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/rendering/blit_compositor.py +0 -0
  36. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/rendering/contour_overlay.py +0 -0
  37. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/rendering/drawing_manager.py +0 -0
  38. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/rendering/dvh.py +0 -0
  39. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/rendering/image_layer.py +0 -0
  40. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/rendering/isodose.py +0 -0
  41. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/rendering/layout.py +0 -0
  42. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/rendering/render.py +0 -0
  43. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/roi_operations.py +0 -0
  44. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/rtstruct_io.py +0 -0
  45. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/state/__init__.py +0 -0
  46. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/state/dose_manager.py +0 -0
  47. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/state/phase_manager.py +0 -0
  48. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/state/roi_editor.py +0 -0
  49. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/state/roi_manager.py +0 -0
  50. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/state/secondary_manager.py +0 -0
  51. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/state/structure_set.py +0 -0
  52. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/state/viewer_cache.py +0 -0
  53. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/state/viewer_state.py +0 -0
  54. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/src/tk_rt_viewer/window_level.py +0 -0
  55. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/tests/test_bbox3d.py +0 -0
  56. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/tests/test_bbox3d_handler.py +0 -0
  57. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/tests/test_brush_handler.py +0 -0
  58. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/tests/test_geometry.py +0 -0
  59. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/tests/test_io.py +0 -0
  60. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/tests/test_isodose_levels.py +0 -0
  61. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/tests/test_performance_opt.py +0 -0
  62. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/tests/test_reg_io.py +0 -0
  63. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/tests/test_registration.py +0 -0
  64. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/tests/test_render.py +0 -0
  65. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/tests/test_rendering.py +0 -0
  66. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/tests/test_roi_operations.py +0 -0
  67. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/tests/test_rtstruct_io.py +0 -0
  68. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/tests/test_state_extensions.py +0 -0
  69. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/tests/test_state_managers.py +0 -0
  70. {tk_rt_viewer-2.3.3 → tk_rt_viewer-2.3.5}/tests/test_viewer_state.py +0 -0
@@ -5,6 +5,9 @@ on:
5
5
  branches: [main]
6
6
  pull_request:
7
7
 
8
+ permissions:
9
+ contents: read
10
+
8
11
  jobs:
9
12
  check:
10
13
  runs-on: ubuntu-latest
@@ -4,6 +4,40 @@ All notable changes to this project are documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [2.3.5]
8
+
9
+ ### Fixed
10
+
11
+ - **The toolbar's Home button works again.** Its click (and Back / Forward)
12
+ raised `TypeError: ImageViewAxes._set_view() missing 3 required positional
13
+ arguments`, because `ImageViewAxes` defined a `_set_view(cx, cy, span_x,
14
+ span_y)` that shadowed Matplotlib's `Axes._set_view(view)`, which the
15
+ navigation toolbar calls to restore a saved view. The private helper is now
16
+ `ImageViewAxes._apply_view`, so Matplotlib's own `_get_view` / `_set_view`
17
+ are inherited again and the toolbar's zoom-rectangle and pan history can be
18
+ stepped through with Back / Forward.
19
+ - **Home fits the views after Ctrl + wheel zoom and middle-button pan.** Neither
20
+ goes through the toolbar's view history, so Home had nothing to return to
21
+ and did nothing. Home now calls `DicomViewer.reset_zoom()` and fits every
22
+ view. Back / Forward are unchanged: they still replay only the toolbar's own
23
+ zoom and pan, not the wheel zoom or the middle-button pan.
24
+ - Switching the layout now clears the toolbar's view history, which named the
25
+ Axes discarded by the switch.
26
+
27
+ ## [2.3.4]
28
+
29
+ ### Added
30
+
31
+ - **Middle-button panning.** Pressing the middle mouse button (the wheel) over
32
+ a view and dragging moves the view so that the image follows the pointer.
33
+ Each view pans independently, at any zoom, and the view cannot be moved off
34
+ the slice. It works even while the brush tool is active, like Ctrl + wheel
35
+ zoom, and does not touch `SliceViewerState`. `reset_zoom()` fits the view
36
+ again, which also undoes the pan.
37
+ - `ImageViewAxes.view_center()` returns the data coordinates of the view
38
+ centre, and `ImageViewAxes.pan_to(cx, cy)` centres the view on a point at
39
+ the current zoom (clamped to the slice).
40
+
7
41
  ## [2.3.3]
8
42
 
9
43
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: tk-rt-viewer
3
- Version: 2.3.3
3
+ Version: 2.3.5
4
4
  Summary: SimpleITK-based DICOM-RT MPR viewer widget for Tkinter (CT, RT-DOSE, RT-STRUCT, DVH)
5
5
  Project-URL: Homepage, https://github.com/oki1002/DICOM_RT_Viewer
6
6
  Project-URL: Repository, https://github.com/oki1002/DICOM_RT_Viewer
@@ -59,7 +59,7 @@ The distribution name on PyPI is `tk-rt-viewer`; the import package is
59
59
  - **Observer-pattern state management** — All view state lives in `SliceViewerState`; the widget reacts to changes without polling.
60
60
  - **SimpleITK-native coordinates** — Physical LPS coordinates, origin, spacing, and direction cosines are preserved throughout; axis reordering between SimpleITK and NumPy conventions is handled internally by the library.
61
61
  - **Interactive navigation** — Crosshair drag, mouse wheel (direction reversible), and keyboard (↑ / ↓ / PageUp / PageDown).
62
- - **Per-view zoom** — Ctrl + mouse wheel zooms the view under the pointer about the pointer; each view keeps its own zoom factor. The views fill their layout cells, so a zoomed slice uses the whole cell.
62
+ - **Per-view zoom and pan** — Ctrl + mouse wheel zooms the view under the pointer about the pointer, and dragging with the middle button (the wheel pressed) pans it; each view keeps its own zoom factor and position; the toolbar's Home button fits every view again. The views fill their layout cells, so a zoomed slice uses the whole cell.
63
63
  - **Independent window / level per image** — The primary and secondary images each carry their own display window, so a PET, MR, or dose overlay can be windowed without disturbing the CT underneath. The secondary follows the primary until an override is set. Right-click drag adjusts whichever image is targeted: horizontal → window width (WW), vertical → window centre (WL).
64
64
  - **RT-STRUCT support** — ROI masks stored in `StructureSet` (keyed by integer ROI number); contour overlay with optional semi-transparent fill; brush tool for mask editing.
65
65
  - **ROI operations** — Shape-based inter-slice interpolation, true Euclidean margins (uniform or 6-direction anisotropic), Gaussian smoothing, and boolean operations (union / intersection / subtraction).
@@ -134,7 +134,7 @@ tk_rt_viewer/
134
134
  │ ├── isodose.py # IsoDoseOverlay (fill bands + contour lines)
135
135
  │ ├── dvh.py # DvhPanel (cumulative DVH panel)
136
136
  │ ├── layout.py # LayoutManager (single / mpr / mpr_wide layouts)
137
- │ └── view_axes.py # ImageViewAxes (fills its cell, 1:1 aspect, zoom)
137
+ │ └── view_axes.py # ImageViewAxes (fills its cell, 1:1 aspect, zoom, pan)
138
138
  ├── registration/
139
139
  │ ├── session.py # RegistrationSession, cropping, resampling
140
140
  │ ├── params.py # RigidParams <-> transforms (Vert/Lat/Long/...)
@@ -759,7 +759,7 @@ box tool, crosshair, contours, isodose) works unchanged in `"single"` mode
759
759
  against the `"axial"` key — host code does not need a separate code path
760
760
  for it.
761
761
 
762
- ## Zoom and wheel direction
762
+ ## Zoom, pan and wheel direction
763
763
 
764
764
  Ctrl + mouse wheel zooms the view under the pointer, keeping the point under
765
765
  the pointer in place. Each view is zoomed independently, from 1× (the whole
@@ -768,11 +768,29 @@ the slice. A figure resize keeps each view's zoom and centre; loading a new
768
768
  primary image or switching the layout starts fitted again. Ctrl + wheel zooms
769
769
  even while the brush tool is active (the plain wheel still resizes the brush).
770
770
 
771
+ Dragging with the middle button (the wheel pressed) pans the view under the
772
+ pointer: the image follows the pointer, at any zoom, and the view cannot be
773
+ moved off the slice. Each view pans independently, and panning also works
774
+ while the brush tool is active. `reset_zoom()` fits the view again, which
775
+ undoes the pan as well. A view keeps its position across a figure resize and
776
+ starts fitted when a new primary image is loaded or the layout is switched.
777
+
778
+ The toolbar's Home button does the same as `reset_zoom()`: it fits every view,
779
+ undoing Ctrl + wheel zoom and middle-button pan. The toolbar's Back / Forward
780
+ buttons step through the toolbar's own zoom-rectangle and pan history only;
781
+ Ctrl + wheel zoom and middle-button pan are not recorded there.
782
+
771
783
  ```python
772
784
  viewer.set_zoom("axial", 2.5) # about the view centre
773
785
  viewer.set_zoom("coronal", 4.0, anchor=(x, z)) # keep (x, z) in place
774
786
  viewer.get_zoom("axial") # -> 2.5
775
- viewer.reset_zoom() # fit every view again
787
+ viewer.reset_zoom() # fit every view again (and undo any pan)
788
+
789
+ # Pan programmatically through the view's Axes
790
+ ax = viewer.axs["axial"]
791
+ ax.view_center() # -> (x, y) in data coordinates
792
+ ax.pan_to(x, y) # centre on (x, y), clamped to the slice
793
+ viewer.canvas.draw_idle()
776
794
 
777
795
  # Reverse the wheel for slice scrolling (brush size and zoom are unaffected)
778
796
  viewer = DicomViewer(parent, state=state, invert_scroll=True)
@@ -22,7 +22,7 @@ The distribution name on PyPI is `tk-rt-viewer`; the import package is
22
22
  - **Observer-pattern state management** — All view state lives in `SliceViewerState`; the widget reacts to changes without polling.
23
23
  - **SimpleITK-native coordinates** — Physical LPS coordinates, origin, spacing, and direction cosines are preserved throughout; axis reordering between SimpleITK and NumPy conventions is handled internally by the library.
24
24
  - **Interactive navigation** — Crosshair drag, mouse wheel (direction reversible), and keyboard (↑ / ↓ / PageUp / PageDown).
25
- - **Per-view zoom** — Ctrl + mouse wheel zooms the view under the pointer about the pointer; each view keeps its own zoom factor. The views fill their layout cells, so a zoomed slice uses the whole cell.
25
+ - **Per-view zoom and pan** — Ctrl + mouse wheel zooms the view under the pointer about the pointer, and dragging with the middle button (the wheel pressed) pans it; each view keeps its own zoom factor and position; the toolbar's Home button fits every view again. The views fill their layout cells, so a zoomed slice uses the whole cell.
26
26
  - **Independent window / level per image** — The primary and secondary images each carry their own display window, so a PET, MR, or dose overlay can be windowed without disturbing the CT underneath. The secondary follows the primary until an override is set. Right-click drag adjusts whichever image is targeted: horizontal → window width (WW), vertical → window centre (WL).
27
27
  - **RT-STRUCT support** — ROI masks stored in `StructureSet` (keyed by integer ROI number); contour overlay with optional semi-transparent fill; brush tool for mask editing.
28
28
  - **ROI operations** — Shape-based inter-slice interpolation, true Euclidean margins (uniform or 6-direction anisotropic), Gaussian smoothing, and boolean operations (union / intersection / subtraction).
@@ -97,7 +97,7 @@ tk_rt_viewer/
97
97
  │ ├── isodose.py # IsoDoseOverlay (fill bands + contour lines)
98
98
  │ ├── dvh.py # DvhPanel (cumulative DVH panel)
99
99
  │ ├── layout.py # LayoutManager (single / mpr / mpr_wide layouts)
100
- │ └── view_axes.py # ImageViewAxes (fills its cell, 1:1 aspect, zoom)
100
+ │ └── view_axes.py # ImageViewAxes (fills its cell, 1:1 aspect, zoom, pan)
101
101
  ├── registration/
102
102
  │ ├── session.py # RegistrationSession, cropping, resampling
103
103
  │ ├── params.py # RigidParams <-> transforms (Vert/Lat/Long/...)
@@ -722,7 +722,7 @@ box tool, crosshair, contours, isodose) works unchanged in `"single"` mode
722
722
  against the `"axial"` key — host code does not need a separate code path
723
723
  for it.
724
724
 
725
- ## Zoom and wheel direction
725
+ ## Zoom, pan and wheel direction
726
726
 
727
727
  Ctrl + mouse wheel zooms the view under the pointer, keeping the point under
728
728
  the pointer in place. Each view is zoomed independently, from 1× (the whole
@@ -731,11 +731,29 @@ the slice. A figure resize keeps each view's zoom and centre; loading a new
731
731
  primary image or switching the layout starts fitted again. Ctrl + wheel zooms
732
732
  even while the brush tool is active (the plain wheel still resizes the brush).
733
733
 
734
+ Dragging with the middle button (the wheel pressed) pans the view under the
735
+ pointer: the image follows the pointer, at any zoom, and the view cannot be
736
+ moved off the slice. Each view pans independently, and panning also works
737
+ while the brush tool is active. `reset_zoom()` fits the view again, which
738
+ undoes the pan as well. A view keeps its position across a figure resize and
739
+ starts fitted when a new primary image is loaded or the layout is switched.
740
+
741
+ The toolbar's Home button does the same as `reset_zoom()`: it fits every view,
742
+ undoing Ctrl + wheel zoom and middle-button pan. The toolbar's Back / Forward
743
+ buttons step through the toolbar's own zoom-rectangle and pan history only;
744
+ Ctrl + wheel zoom and middle-button pan are not recorded there.
745
+
734
746
  ```python
735
747
  viewer.set_zoom("axial", 2.5) # about the view centre
736
748
  viewer.set_zoom("coronal", 4.0, anchor=(x, z)) # keep (x, z) in place
737
749
  viewer.get_zoom("axial") # -> 2.5
738
- viewer.reset_zoom() # fit every view again
750
+ viewer.reset_zoom() # fit every view again (and undo any pan)
751
+
752
+ # Pan programmatically through the view's Axes
753
+ ax = viewer.axs["axial"]
754
+ ax.view_center() # -> (x, y) in data coordinates
755
+ ax.pan_to(x, y) # centre on (x, y), clamped to the slice
756
+ viewer.canvas.draw_idle()
739
757
 
740
758
  # Reverse the wheel for slice scrolling (brush size and zoom are unaffected)
741
759
  viewer = DicomViewer(parent, state=state, invert_scroll=True)
@@ -104,7 +104,7 @@ __all__ = [
104
104
  "StructureSet",
105
105
  "to_gy_pairs",
106
106
  ]
107
- __version__ = "2.3.3"
107
+ __version__ = "2.3.5"
108
108
 
109
109
 
110
110
  def __getattr__(name: str) -> Any:
@@ -4,8 +4,10 @@ Responsibilities:
4
4
  - Track which view the pointer is inside.
5
5
  - Route canvas events to the appropriate sub-handler.
6
6
  - Implement right-click-drag window / level adjustment directly.
7
+ - Implement middle-button-drag panning directly.
7
8
 
8
9
  Event priority for ``on_press`` / ``on_motion``:
10
+ 0. Pan (middle-button drag; works even while the brush is active)
9
11
  1. Brush tool (exclusive when active)
10
12
  2. Crosshair drag
11
13
  3. Window / level adjustment (right-click drag)
@@ -28,6 +30,13 @@ Wheel priority:
28
30
  the brush is active
29
31
  2. Brush tool: resize the brush
30
32
  3. Otherwise: scroll slices; ``invert_scroll`` flips the direction
33
+
34
+ Pan:
35
+ Pressing the middle button (the wheel) over a view and dragging moves the
36
+ view so that the image follows the pointer. The drag is measured from the
37
+ press, so the image tracks the pointer exactly until the view reaches the
38
+ edge of the slice. Panning only changes the view limits; it does not
39
+ touch the state.
31
40
  """
32
41
 
33
42
  import numpy as np
@@ -42,7 +51,7 @@ from .brush_handler import BrushEventHandler
42
51
  from .crosshair_handler import CrosshairEventHandler
43
52
 
44
53
  #: Zoom ratio per Ctrl + wheel notch.
45
- ZOOM_STEP: float = 1.25
54
+ ZOOM_STEP: float = 1.1
46
55
 
47
56
  #: Debounce window (ms) for batching scroll events; short enough to feel
48
57
  #: immediate, long enough to coalesce a wheel flick.
@@ -54,6 +63,9 @@ _KEY_STEPS: dict[str, int] = {"up": 1, "down": -1, "pageup": 10, "pagedown": -10
54
63
  # Right mouse button drives the window/level drag
55
64
  _WL_BUTTON: int = 3
56
65
 
66
+ # Middle mouse button (wheel press) drives the pan drag
67
+ _PAN_BUTTON: int = 2
68
+
57
69
  # Window/level drag sensitivity (display units per pixel) at the reference
58
70
  # width; scaled by the window at drag start so a 400 HU and a 4 Gy window
59
71
  # feel alike
@@ -95,6 +107,13 @@ class ViewerEventHandler:
95
107
  self._wl_initial: tuple[float, float] | None = None
96
108
  self._wl_target: str = "primary"
97
109
 
110
+ # Pan drag state: the view being panned and the pointer position
111
+ # (display pixels) and view limits at the press. ``None`` when idle.
112
+ self._pan_axis: str = ""
113
+ self._pan_start: (
114
+ tuple[float, float, tuple[float, float], tuple[float, float]] | None
115
+ ) = None
116
+
98
117
  # Scroll debounce state (Tk main thread only)
99
118
  self._scroll_handle: str | None = None
100
119
  self._scroll_accum: int = 0
@@ -117,6 +136,7 @@ class ViewerEventHandler:
117
136
  self.brush_handler.activate()
118
137
  # The brush claims the mouse: abandon every other drag
119
138
  self._reset_wl_drag()
139
+ self._end_pan()
120
140
  self.crosshair_handler.cancel()
121
141
  self.bbox_handler.cancel()
122
142
  self.bbox_3d_handler.cancel()
@@ -256,6 +276,11 @@ class ViewerEventHandler:
256
276
  if self._any_drag_in_progress():
257
277
  self._recover_lost_drag(event)
258
278
 
279
+ # Priority 0: pan, even while the brush is active
280
+ if event.button == _PAN_BUTTON:
281
+ self._begin_pan(event)
282
+ return
283
+
259
284
  # Priority 1: brush tool (exclusive)
260
285
  if self.state.brush_tool_active:
261
286
  self.brush_handler.handle_press(event)
@@ -276,6 +301,53 @@ class ViewerEventHandler:
276
301
  return
277
302
  self.bbox_handler.handle_press(event)
278
303
 
304
+ # ------------------------------------------------------------------
305
+ # Pan
306
+ # ------------------------------------------------------------------
307
+ def _begin_pan(self, event) -> None:
308
+ """Start panning the view under the pointer, if it can be panned."""
309
+ ax = self.viewer.axes_map.get(self._current_axis)
310
+ if (
311
+ not isinstance(ax, ImageViewAxes)
312
+ or self.state.primary_image is None
313
+ or event.x is None
314
+ or event.y is None
315
+ ):
316
+ return
317
+ self._pan_axis = self._current_axis
318
+ self._pan_start = (event.x, event.y, ax.get_xlim(), ax.get_ylim())
319
+
320
+ def _apply_pan(self, event) -> None:
321
+ """Move the view so the image follows the pointer since the press.
322
+
323
+ The shift is converted from display pixels to data units with the
324
+ limits at the press, so it keeps its sign on an inverted axis.
325
+ """
326
+ ax = self.viewer.axes_map.get(self._pan_axis)
327
+ if (
328
+ self._pan_start is None
329
+ or not isinstance(ax, ImageViewAxes)
330
+ or event.x is None
331
+ or event.y is None
332
+ ):
333
+ return
334
+ width, height = ax.bbox.width, ax.bbox.height
335
+ if width <= 0 or height <= 0:
336
+ return
337
+ start_x, start_y, xlim, ylim = self._pan_start
338
+ shift_x = (event.x - start_x) / width * (xlim[1] - xlim[0])
339
+ shift_y = (event.y - start_y) / height * (ylim[1] - ylim[0])
340
+ ax.pan_to(
341
+ (xlim[0] + xlim[1]) / 2 - shift_x,
342
+ (ylim[0] + ylim[1]) / 2 - shift_y,
343
+ )
344
+ self.viewer.refresh_canvas()
345
+
346
+ def _end_pan(self) -> None:
347
+ """Clear all pan drag state."""
348
+ self._pan_axis = ""
349
+ self._pan_start = None
350
+
279
351
  def _begin_wl_drag(self, event) -> None:
280
352
  """Start a window/level drag, resolving its target image once.
281
353
 
@@ -311,6 +383,9 @@ class ViewerEventHandler:
311
383
  self._recover_lost_drag(event)
312
384
  return
313
385
 
386
+ if self._pan_start is not None:
387
+ self._apply_pan(event)
388
+ return
314
389
  if self.state.brush_tool_active:
315
390
  self.brush_handler.handle_motion(event)
316
391
  return
@@ -341,11 +416,12 @@ class ViewerEventHandler:
341
416
  return event.button is None
342
417
 
343
418
  def _any_drag_in_progress(self) -> bool:
344
- """``True`` if any sub-handler (or the W/L drag) is mid-drag."""
419
+ """``True`` if any sub-handler (or the W/L or pan drag) is mid-drag."""
345
420
  return (
346
421
  self.brush_handler.is_dragging
347
422
  or self.crosshair_handler.is_dragging
348
423
  or self._dragging_wl
424
+ or self._pan_start is not None
349
425
  or self.bbox_handler.is_dragging
350
426
  or self.bbox_3d_handler.is_dragging
351
427
  )
@@ -366,6 +442,8 @@ class ViewerEventHandler:
366
442
  self.bbox_3d_handler.cancel()
367
443
  if self._dragging_wl:
368
444
  self._reset_wl_drag()
445
+ if self._pan_start is not None:
446
+ self._end_pan()
369
447
 
370
448
  def _apply_wl_drag(self, event) -> None:
371
449
  """Translate a right-drag into a window/level change.
@@ -395,6 +473,10 @@ class ViewerEventHandler:
395
473
  # ------------------------------------------------------------------
396
474
  def on_release(self, event) -> None:
397
475
  """Release all in-progress drag operations."""
476
+ if event.button == _PAN_BUTTON and self._pan_start is not None:
477
+ self._end_pan()
478
+ return
479
+
398
480
  if self.state.brush_tool_active:
399
481
  self.brush_handler.handle_release(event)
400
482
  return
@@ -1,4 +1,4 @@
1
- """view_axes.py — Axes for an image view: fills its cell, keeps 1:1, zooms.
1
+ """view_axes.py — Axes for an image view: fills its cell, keeps 1:1, zooms, pans.
2
2
 
3
3
  Matplotlib keeps an equal data aspect either by shrinking the Axes box
4
4
  (``adjustable="box"``, which leaves empty bands in the layout cell) or by
@@ -10,6 +10,9 @@ conformed to the box on every draw.
10
10
  Zoom is relative to the "fit" view, in which the whole slice just fits the
11
11
  box. It is read back from the limits, so a Matplotlib toolbar zoom or pan is
12
12
  picked up as well; after a resize the zoom factor and centre are kept.
13
+
14
+ Panning (:meth:`ImageViewAxes.pan_to`) moves the view centre at a fixed zoom;
15
+ like zooming, it never moves the view off the slice.
13
16
  """
14
17
 
15
18
  from matplotlib.axes import Axes
@@ -85,7 +88,26 @@ class ImageViewAxes(Axes):
85
88
  if anchor is not None and old_x > 0 and old_y > 0:
86
89
  cx = anchor[0] + (cx - anchor[0]) * new_x / old_x
87
90
  cy = anchor[1] + (cy - anchor[1]) * new_y / old_y
88
- self._set_view(cx, cy, new_x, new_y)
91
+ self._apply_view(cx, cy, new_x, new_y)
92
+
93
+ def view_center(self) -> tuple[float, float]:
94
+ """Return the data coordinates of the centre of the current view."""
95
+ return self._center()
96
+
97
+ def pan_to(self, cx: float, cy: float) -> None:
98
+ """Centre the view on ``(cx, cy)`` without changing the zoom.
99
+
100
+ The centre is clamped so that the view stays on the slice; a view at
101
+ least as wide as the slice along an axis stays centred on it there.
102
+
103
+ Args:
104
+ cx: Target centre, x in data coordinates.
105
+ cy: Target centre, y in data coordinates.
106
+ """
107
+ span_x, span_y = self._spans()
108
+ if span_x <= 0 or span_y <= 0:
109
+ return
110
+ self._apply_view(cx, cy, span_x, span_y)
89
111
 
90
112
  # ------------------------------------------------------------------
91
113
  # Internals
@@ -121,11 +143,15 @@ class ImageViewAxes(Axes):
121
143
  else:
122
144
  span_x = span_y / ratio
123
145
 
124
- self._set_view(cx, cy, span_x, span_y)
146
+ self._apply_view(cx, cy, span_x, span_y)
125
147
  self._conformed = (self.get_xlim(), self.get_ylim(), ratio)
126
148
 
127
- def _set_view(self, cx: float, cy: float, span_x: float, span_y: float) -> None:
128
- """Set the limits around a centre, clamped to the slice, keeping inversion."""
149
+ def _apply_view(self, cx: float, cy: float, span_x: float, span_y: float) -> None:
150
+ """Set the limits around a centre, clamped to the slice, keeping inversion.
151
+
152
+ Not named ``_set_view``: that name belongs to Matplotlib's Axes, which
153
+ the navigation toolbar calls with one saved-view argument.
154
+ """
129
155
  if self._image_extent is not None:
130
156
  x0, x1, y0, y1 = self._image_extent
131
157
  cx = _clamp_center(cx, span_x, x0, x1)
@@ -29,6 +29,11 @@ Zoom:
29
29
  each view independently (``set_zoom`` / ``get_zoom`` / ``reset_zoom``).
30
30
  The views fill their layout cells; a new image or layout starts fitted.
31
31
 
32
+ Pan:
33
+ Dragging with the middle button (the wheel pressed) moves the view under
34
+ the pointer, each view independently and at any zoom, even while the brush
35
+ is active. The view cannot leave the slice; ``reset_zoom`` fits it again.
36
+
32
37
  Window / level:
33
38
  Right-click drag: horizontal -> width, vertical -> centre, applied to
34
39
  ``state.window_level_target``; Shift targets the other image for that
@@ -93,6 +98,25 @@ from .state.viewer_state import SliceViewerState
93
98
  logger = logging.getLogger(__name__)
94
99
 
95
100
 
101
+ class _ViewerToolbar(NavigationToolbar2Tk):
102
+ """Navigation toolbar whose Home button fits every view.
103
+
104
+ Ctrl + wheel zoom and middle-button pan do not go through the toolbar's
105
+ view history, so its own Home would have nothing to return to.
106
+ """
107
+
108
+ def __init__(
109
+ self, canvas: FigureCanvasTkAgg, window: tk.Widget, on_home: Callable[[], None]
110
+ ) -> None:
111
+ # Must be set first: the base class binds the buttons while building
112
+ self._on_home = on_home
113
+ super().__init__(canvas, window)
114
+
115
+ def home(self, *args) -> None:
116
+ """Fit the views instead of replaying the toolbar's view history."""
117
+ self._on_home()
118
+
119
+
96
120
  class DicomViewer(ttk.Frame):
97
121
  """Three-plane MPR viewer widget for Tkinter.
98
122
 
@@ -180,7 +204,7 @@ class DicomViewer(ttk.Frame):
180
204
  )
181
205
  self.canvas = FigureCanvasTkAgg(self.fig, master=self)
182
206
  self.canvas.get_tk_widget().pack(fill=tk.BOTH, expand=True)
183
- self.toolbar = NavigationToolbar2Tk(self.canvas, self)
207
+ self.toolbar = _ViewerToolbar(self.canvas, self, on_home=self.reset_zoom)
184
208
  self.toolbar.update()
185
209
  self.toolbar.pack(side=tk.BOTTOM, fill=tk.X)
186
210
 
@@ -759,6 +783,8 @@ class DicomViewer(ttk.Frame):
759
783
  self._compositor.cancel_pending()
760
784
 
761
785
  self.fig.clear()
786
+ # The toolbar's view history names the Axes that were just discarded
787
+ self.toolbar.update()
762
788
  self._layout_mode = mode
763
789
  self.axs, self._dvh_ax = self.layout.build(mode)
764
790
  self._reset_artists()
@@ -879,7 +905,10 @@ class DicomViewer(ttk.Frame):
879
905
  self.canvas.draw_idle()
880
906
 
881
907
  def reset_zoom(self, axis: str | None = None) -> None:
882
- """Fit the whole slice into *axis*, or into every view when ``None``."""
908
+ """Fit the whole slice into *axis*, or into every view when ``None``.
909
+
910
+ This also undoes any pan: a fitted view is centred on the slice.
911
+ """
883
912
  for name in [axis] if axis is not None else list(self.axs):
884
913
  self.set_zoom(name, 1.0)
885
914
 
@@ -15,10 +15,11 @@ matplotlib.use("Agg")
15
15
  import numpy as np
16
16
  import pytest
17
17
  import SimpleITK as sitk
18
+ from matplotlib.backend_bases import NavigationToolbar2
18
19
  from matplotlib.backends.backend_agg import FigureCanvasAgg
19
20
  from matplotlib.figure import Figure
20
21
 
21
- from tk_rt_viewer.event_controllers.viewer_events import ViewerEventHandler
22
+ from tk_rt_viewer.event_controllers.viewer_events import ZOOM_STEP, ViewerEventHandler
22
23
  from tk_rt_viewer.protocols import ViewerHost
23
24
  from tk_rt_viewer.rendering.view_axes import ImageViewAxes
24
25
  from tk_rt_viewer.state.viewer_state import SliceViewerState
@@ -365,7 +366,7 @@ class TestZoom:
365
366
  ScrollEvent(step=1, xdata=anchor[0], ydata=anchor[1], modifiers={"ctrl"})
366
367
  )
367
368
  axial.apply_aspect()
368
- assert axial.zoom_factor() == pytest.approx(1.25)
369
+ assert axial.zoom_factor() == pytest.approx(ZOOM_STEP)
369
370
  assert x_fraction(axial, anchor[0]) == pytest.approx(frac)
370
371
  assert dict(state.indices) == before # no slice scroll
371
372
  assert axial.yaxis_inverted() # radiological orientation kept
@@ -390,7 +391,7 @@ class TestZoom:
390
391
  state, handler, axial, _coronal = self._setup()
391
392
  state.set_brush_tool_active(True)
392
393
  handler.on_scroll(ScrollEvent(step=1, xdata=8.0, ydata=4.0, modifiers={"ctrl"}))
393
- assert axial.zoom_factor() == pytest.approx(1.25)
394
+ assert axial.zoom_factor() == pytest.approx(ZOOM_STEP)
394
395
 
395
396
  def test_a_resize_keeps_the_zoom_and_the_centre(self) -> None:
396
397
  _state, _handler, axial, _coronal = self._setup()
@@ -418,6 +419,189 @@ class TestZoom:
418
419
  assert "aspect" not in caplog.text
419
420
 
420
421
 
422
+ class TestPan:
423
+ def _setup(self, zoom: float = 3.0):
424
+ state = loaded_state((8, 16, 32))
425
+ axial = zoomable_axes(state, "axial")
426
+ handler, viewer = handler_for(state, FakeViewer({"axial": axial}))
427
+ handler.on_enter_axes(Event(inaxes=axial))
428
+ axial.zoom_to(zoom, anchor=(16.0, 8.0))
429
+ return state, handler, axial
430
+
431
+ @staticmethod
432
+ def _display_of(ax, point) -> np.ndarray:
433
+ return ax.transData.transform(point)
434
+
435
+ def test_the_image_follows_the_pointer(self) -> None:
436
+ _state, handler, axial = self._setup()
437
+ start = (200.0, 120.0)
438
+ grabbed = axial.transData.inverted().transform(start)
439
+ handler.on_press(Event(button=2, x=start[0], y=start[1]))
440
+ handler.on_motion(Event(button=2, x=start[0] + 15, y=start[1] + 9))
441
+ # The data point under the pointer at the press is still under it
442
+ assert self._display_of(axial, grabbed) == pytest.approx(
443
+ (start[0] + 15, start[1] + 9)
444
+ )
445
+ assert axial.zoom_factor() == pytest.approx(3.0)
446
+ assert axial.yaxis_inverted() # radiological orientation kept
447
+
448
+ def test_the_drag_is_measured_from_the_press(self) -> None:
449
+ _state, handler, axial = self._setup()
450
+ handler.on_press(Event(button=2, x=200, y=120))
451
+ handler.on_motion(Event(button=2, x=215, y=129))
452
+ handler.on_motion(Event(button=2, x=170, y=100))
453
+ handler.on_motion(Event(button=2, x=215, y=129))
454
+ grabbed_after_a = axial.view_center()
455
+ handler.on_motion(Event(button=2, x=170, y=100))
456
+ handler.on_motion(Event(button=2, x=215, y=129))
457
+ assert axial.view_center() == pytest.approx(grabbed_after_a)
458
+
459
+ def test_the_view_stays_on_the_slice(self) -> None:
460
+ state, handler, axial = self._setup()
461
+ x0, x1, y0, y1 = state.get_extent("axial")
462
+ handler.on_press(Event(button=2, x=200, y=120))
463
+ for dx, dy in [(10_000, 10_000), (-10_000, -10_000)]:
464
+ handler.on_motion(Event(button=2, x=200 + dx, y=120 + dy))
465
+ assert min(axial.get_xlim()) >= x0 - 1e-9
466
+ assert max(axial.get_xlim()) <= x1 + 1e-9
467
+ assert min(axial.get_ylim()) >= min(y0, y1) - 1e-9
468
+ assert max(axial.get_ylim()) <= max(y0, y1) + 1e-9
469
+
470
+ def test_a_fitted_view_does_not_move(self) -> None:
471
+ _state, handler, axial = self._setup(zoom=1.0)
472
+ before = [*axial.get_xlim(), *axial.get_ylim()]
473
+ handler.on_press(Event(button=2, x=200, y=120))
474
+ handler.on_motion(Event(button=2, x=260, y=60))
475
+ assert [*axial.get_xlim(), *axial.get_ylim()] == pytest.approx(before)
476
+
477
+ def test_release_ends_the_drag(self) -> None:
478
+ _state, handler, axial = self._setup()
479
+ handler.on_press(Event(button=2, x=200, y=120))
480
+ handler.on_motion(Event(button=2, x=215, y=129))
481
+ handler.on_release(Event(button=2, x=215, y=129))
482
+ centre = axial.view_center()
483
+ handler.on_motion(Event(button=2, x=300, y=200))
484
+ assert axial.view_center() == centre
485
+
486
+ def test_a_lost_release_ends_the_drag(self) -> None:
487
+ _state, handler, axial = self._setup()
488
+ handler.on_press(Event(button=2, x=200, y=120))
489
+ handler.on_motion(Event(button=2, x=215, y=129))
490
+ centre = axial.view_center()
491
+ handler.on_motion(Event(button=None, x=300, y=200)) # no button held
492
+ assert axial.view_center() == centre
493
+ handler.on_motion(Event(button=2, x=320, y=220))
494
+ assert axial.view_center() == centre
495
+
496
+ def test_pan_works_with_the_brush_active(self) -> None:
497
+ state, handler, axial = self._setup()
498
+ state.set_brush_tool_active(True)
499
+ centre = axial.view_center()
500
+ handler.on_press(Event(button=2, x=200, y=120))
501
+ handler.on_motion(Event(button=2, x=215, y=129))
502
+ handler.on_release(Event(button=2, x=215, y=129))
503
+ assert axial.view_center() != centre
504
+ assert not handler.brush_handler.is_dragging
505
+
506
+ def test_other_buttons_do_not_pan(self) -> None:
507
+ state, handler, axial = self._setup()
508
+ centre = axial.view_center()
509
+ window_level = state.window_level
510
+ handler.on_press(Event(button=1, x=200, y=120))
511
+ handler.on_motion(Event(button=1, x=215, y=129))
512
+ handler.on_release(Event(button=1, x=215, y=129))
513
+ assert axial.view_center() == centre
514
+ assert state.window_level == window_level
515
+
516
+ def test_the_toolbar_owns_the_mouse(self) -> None:
517
+ _state, handler, axial = self._setup()
518
+ handler.viewer.toolbar_mode = "pan/zoom"
519
+ centre = axial.view_center()
520
+ handler.on_press(Event(button=2, x=200, y=120))
521
+ handler.on_motion(Event(button=2, x=215, y=129))
522
+ assert axial.view_center() == centre
523
+
524
+ def test_a_press_outside_every_view_is_ignored(self) -> None:
525
+ _state, handler, axial = self._setup()
526
+ handler.on_leave_axes(Event(inaxes=None))
527
+ centre = axial.view_center()
528
+ handler.on_press(Event(button=2, x=200, y=120))
529
+ handler.on_motion(Event(button=2, x=215, y=129))
530
+ assert axial.view_center() == centre
531
+
532
+ def test_activating_the_brush_cancels_a_pan(self) -> None:
533
+ state, handler, axial = self._setup()
534
+ handler.on_press(Event(button=2, x=200, y=120))
535
+ state.set_brush_tool_active(True)
536
+ centre = axial.view_center()
537
+ handler.on_motion(Event(button=2, x=215, y=129))
538
+ assert axial.view_center() == centre
539
+
540
+
541
+ class TestImageViewAxesPan:
542
+ def test_pan_to_moves_the_centre_and_keeps_the_zoom(self) -> None:
543
+ state = loaded_state((8, 16, 32))
544
+ axial = zoomable_axes(state, "axial")
545
+ axial.zoom_to(4.0)
546
+ axial.pan_to(5.0, 3.0)
547
+ assert axial.view_center() == pytest.approx((5.0, 3.0))
548
+ assert axial.zoom_factor() == pytest.approx(4.0)
549
+
550
+ def test_pan_to_is_clamped_to_the_slice(self) -> None:
551
+ state = loaded_state((8, 16, 32))
552
+ axial = zoomable_axes(state, "axial")
553
+ x0, x1, _y0, _y1 = state.get_extent("axial")
554
+ axial.zoom_to(4.0)
555
+ axial.pan_to(1e6, 1e6)
556
+ assert max(axial.get_xlim()) == pytest.approx(x1)
557
+ axial.pan_to(-1e6, -1e6)
558
+ assert min(axial.get_xlim()) == pytest.approx(x0)
559
+
560
+ def test_fitting_again_undoes_the_pan(self) -> None:
561
+ state = loaded_state((8, 16, 32))
562
+ axial = zoomable_axes(state, "axial")
563
+ fitted = axial.view_center()
564
+ axial.zoom_to(4.0)
565
+ axial.pan_to(5.0, 3.0)
566
+ axial.zoom_to(1.0)
567
+ assert axial.view_center() == pytest.approx(fitted)
568
+
569
+
570
+ class TestImageViewAxesToolbarCompatibility:
571
+ """The navigation toolbar saves and restores views through Axes._set_view."""
572
+
573
+ def test_toolbar_view_round_trip_restores_the_limits(self) -> None:
574
+ state = loaded_state((8, 16, 32))
575
+ axial = zoomable_axes(state, "axial")
576
+ saved = axial._get_view()
577
+ axial.zoom_to(4.0)
578
+ axial.pan_to(5.0, 3.0)
579
+ axial._set_view(saved)
580
+ assert axial.get_xlim() == pytest.approx(saved["xlim"])
581
+ assert axial.get_ylim() == pytest.approx(saved["ylim"])
582
+
583
+ def test_toolbar_back_and_home_do_not_raise(self) -> None:
584
+ state = loaded_state((8, 16, 32))
585
+ axial = zoomable_axes(state, "axial")
586
+ toolbar = NavigationToolbar2(axial.figure.canvas)
587
+ toolbar.push_current()
588
+ axial.zoom_to(4.0)
589
+ toolbar.push_current()
590
+ toolbar.back()
591
+ assert axial.zoom_factor() == pytest.approx(1.0)
592
+ toolbar.forward()
593
+ toolbar.home()
594
+ assert axial.zoom_factor() == pytest.approx(1.0)
595
+
596
+ def test_toolbar_update_drops_the_history_of_discarded_axes(self) -> None:
597
+ state = loaded_state((8, 16, 32))
598
+ axial = zoomable_axes(state, "axial")
599
+ toolbar = NavigationToolbar2(axial.figure.canvas)
600
+ toolbar.push_current()
601
+ toolbar.update()
602
+ assert toolbar._nav_stack() is None
603
+
604
+
421
605
  class TestKeyboardNavigation:
422
606
  @pytest.mark.parametrize(
423
607
  "key,expected", [("up", 5), ("down", 3), ("pageup", 7), ("pagedown", 0)]
File without changes
File without changes