@@ -95,8 +95,6 @@ def add_button(self,
9595 "yanchor" : yanchor
9696 })
9797
98- self ._update_buttons ()
99-
10098 def show_hide_bbox_dict (self , toggle : bool = True ):
10199 """Generate dictionary for showing/hiding coordinate system elements.
102100
@@ -137,7 +135,7 @@ def show_hide_bbox_dict(self, toggle: bool = True):
137135 def add_coordinate_system_toggle_button (
138136 self ,
139137 label : str = "Toggle Axes" ,
140- x : float = 0.08 ,
138+ x : float = 0.12 ,
141139 y : float = 1.02
142140 ) -> None :
143141 """Add a button to toggle the coordinate system (axes, grid, labels) on/off.
@@ -207,49 +205,71 @@ def add_dropdown_menu(
207205 "yanchor" : yanchor
208206 })
209207
210- self ._update_dropdowns ()
208+ def update_layout (self ) -> None :
209+ """Update the figure layout with all dropdowns and buttons.
211210
212- def _update_dropdowns ( self ) -> None :
213- """Update the figure layout with all dropdowns and buttons."""
211+ This should be called by the main interface class after all buttons have been added.
212+ """
214213 if not self ._buttons :
215214 return
216215
217- # Create updatemenus for the layout
218- updatemenus = []
216+ # Separate regular buttons from dropdowns
217+ regular_buttons = []
218+ dropdowns = []
219219
220220 for button_info in self ._buttons :
221221 if button_info ["button" ].get ("type" ) == "dropdown" :
222- # This is a dropdown menu
223- updatemenu = button_info ["button" ]
222+ dropdowns .append (button_info )
224223 else :
225- # This is a regular button - create individual updatemenu for each
226- updatemenu = {
227- "type" : "buttons" ,
228- "buttons" : [button_info ["button" ]],
229- "x" : button_info ["x" ],
230- "y" : button_info ["y" ],
231- "xanchor" : button_info ["xanchor" ],
232- "yanchor" : button_info ["yanchor" ],
233- "showactive" : False ,
234- "direction" : "left" ,
235- "bgcolor" : "rgba(255,255,255,0.95)" ,
236- "bordercolor" : "rgba(0,0,0,0.3)" ,
237- "borderwidth" : 1 ,
238- "font" : {"size" : 12 },
239- "pad" : {"t" : 5 , "b" : 5 , "l" : 10 , "r" : 10 }
240- }
224+ regular_buttons .append (button_info ["button" ])
225+
226+ # Create updatemenus for the layout
227+ updatemenus = []
228+
229+ # Add all regular buttons as a single row with "left" direction
230+ if regular_buttons :
231+ updatemenu = {
232+ "type" : "buttons" ,
233+ "buttons" : regular_buttons ,
234+ "x" : 0.02 ,
235+ "y" : 1.02 ,
236+ "xanchor" : "left" ,
237+ "yanchor" : "bottom" ,
238+ "showactive" : False ,
239+ "direction" : "left" ,
240+ "bgcolor" : "rgba(255,255,255,0.95)" ,
241+ "bordercolor" : "rgba(0,0,0,0.3)" ,
242+ "borderwidth" : 1 ,
243+ "font" : {"size" : 12 },
244+ "pad" : {"t" : 5 , "b" : 5 , "l" : 10 , "r" : 10 }
245+ }
241246 updatemenus .append (updatemenu )
242247
248+ # Add dropdowns separately (they need their own updatemenu entries)
249+ for i , dropdown_info in enumerate (dropdowns ):
250+ dropdown_config = dropdown_info ["button" ].copy ()
251+ # Position dropdowns to the right of buttons
252+ button_width = len (regular_buttons ) * 0.08 if regular_buttons else 0
253+ dropdown_config ["x" ] = 0.02 + button_width + (i * 0.12 )
254+ dropdown_config ["y" ] = 1.02
255+ dropdown_config ["xanchor" ] = "left"
256+ dropdown_config ["yanchor" ] = "bottom"
257+ updatemenus .append (dropdown_config )
258+
243259 self ._fig .update_layout (updatemenus = updatemenus )
244260
261+ def _update_dropdowns (self ) -> None :
262+ """Deprecated: Use update_layout() instead."""
263+ self .update_layout ()
264+
245265 def add_plane_view_buttons (
246266 self ,
247267 xy_label : str = "XY View" ,
248268 xz_label : str = "XZ View" ,
249269 yz_label : str = "YZ View" ,
250270 iso_label : str = "ISO View" ,
251271 x : float = 0.02 ,
252- y : float = 1.02 ,
272+ y : float = 1.00 ,
253273 ) -> None :
254274 """Add a dropdown menu for standard plane views (XY, XZ, YZ) and isometric view.
255275
@@ -360,7 +380,7 @@ def add_measurement_toggle_button(
360380 def add_projection_toggle_button (
361381 self ,
362382 label : str = "Toggle Projection" ,
363- x : float = 0.14 ,
383+ x : float = 0.22 ,
364384 y : float = 1.02
365385 ) -> None :
366386 """Add a button to toggle between perspective and orthographic projection.
@@ -396,7 +416,7 @@ def add_projection_toggle_button(
396416 def add_theme_toggle_button (
397417 self ,
398418 label : str = "Toggle Theme" ,
399- x : float = 0.2175 ,
419+ x : float = 0.32 ,
400420 y : float = 1.02
401421 ) -> None :
402422 """Add a button to toggle between light and dark themes.
0 commit comments