2
2
3
3
import napari
4
4
import numpy as np
5
- from qtpy .QtWidgets import QWidget
6
- from magicgui import magicgui
5
+ from qtpy .QtWidgets import QComboBox , QLabel , QVBoxLayout , QWidget
7
6
8
7
from .base import SingleAxesWidget
9
8
from .util import Interval
@@ -71,13 +70,14 @@ def __init__(
71
70
parent : Optional [QWidget ] = None ,):
72
71
super ().__init__ (napari_viewer , parent = parent )
73
72
74
- self ._key_selection_widget = magicgui (
75
- x_axis_key = {"choices" : self ._get_valid_axis_keys },
76
- call_button = "plot" ,
77
- )
78
- self .layout ().addWidget (self ._key_selection_widget .native )
73
+ self .layout ().addLayout (QVBoxLayout ())
74
+ self ._key_selection_widget = QComboBox ()
75
+ self .layout ().addWidget (QLabel ("Key:" ))
76
+ self .layout ().addWidget (self ._key_selection_widget )
79
77
80
- self .update_layers (None )
78
+ self ._key_selection_widget .currentTextChanged .connect (self ._set_axis_keys )
79
+
80
+ self ._update_layers (None )
81
81
82
82
@property
83
83
def x_axis_key (self ) -> Optional [str ]:
@@ -139,17 +139,17 @@ def _get_data(self) -> Tuple[np.ndarray, str]:
139
139
140
140
return data , x_axis_name
141
141
142
- def _on_update_layers (self ) -> None :
142
+ def on_update_layers (self ) -> None :
143
143
"""
144
- This is called when the layer selection changes by
145
- ``self.update_layers()``.
144
+ Called when the layer selection changes by ``self.update_layers()``.
146
145
"""
147
- if hasattr (self , "_key_selection_widget" ):
148
- self ._key_selection_widget .reset_choices ()
149
-
150
146
# reset the axis keys
151
147
self ._x_axis_key = None
152
148
149
+ # Clear combobox
150
+ self ._key_selection_widget .clear ()
151
+ self ._key_selection_widget .addItems (self ._get_valid_axis_keys ())
152
+
153
153
def draw (self ) -> None :
154
154
"""Clear the axes and histogram the currently selected layer/slice."""
155
155
@@ -159,7 +159,7 @@ def draw(self) -> None:
159
159
return
160
160
161
161
self .axes .hist (data , bins = 50 , edgecolor = 'white' ,
162
- linewidth = 0.3 )
162
+ linewidth = 0.3 )
163
163
164
164
# set ax labels
165
165
self .axes .set_xlabel (x_axis_name )
0 commit comments