2020# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121# SOFTWARE.
2222"""Provides a wrapper to aid in plotting."""
23- from abc import abstractmethod
23+ from abc import Callable , abstractmethod
2424import importlib .util
2525from typing import TYPE_CHECKING , Any , Dict , List , Optional , Union
2626
@@ -405,15 +405,43 @@ def disable_hover(self):
405405 """Disable hover capabilities in the plotter."""
406406 self ._hover_widget .EnabledOff ()
407407
408+ def __extract_kwargs (self , func_name : Callable , input_kwargs : Dict [str , Any ]) -> Dict [str , Any ]:
409+ """Extracts the keyword arguments from a function signature and returns it as dict.
410+
411+ Parameters
412+ ----------
413+ func_name : Callable
414+ Function to extract the keyword arguments from. It should be a callable function
415+ input_kwargs : Dict[str, Any]
416+ Dictionary with the keyword arguments to update the extracted ones.
417+
418+ Returns
419+ -------
420+ Dict[str, Any]
421+ Dictionary with the keyword arguments extracted from the function signature and
422+ updated with the input kwargs.
423+ """
424+ import inspect
425+ signature = inspect .signature (func_name )
426+ kwargs = {}
427+ for k , v in signature .parameters .items ():
428+ # We are ignoring positional arguments, and passing everything as kwarg
429+ if v .default is not inspect .Parameter .empty :
430+ kwargs [k ] = v .default
431+ for k , v in kwargs .items ():
432+ # my_args is the arguments passed to the ansys-visualization API
433+ if k in input_kwargs :
434+ kwargs [k ] = input_kwargs [k ]
435+ return kwargs
436+
408437 def show (
409438 self ,
410439 plottable_object : Any = None ,
411440 screenshot : Optional [str ] = None ,
412441 view_2d : Dict = None ,
413442 name_filter : str = None ,
414443 dark_mode : bool = False ,
415- plotting_options : Optional [Dict [str , Any ]] = {},
416- ** show_options : Dict [str , Any ],
444+ ** kwargs : Dict [str , Any ],
417445 ) -> List [Any ]:
418446 """Plot and show any PyAnsys object.
419447
@@ -432,10 +460,7 @@ def show(
432460 Regular expression with the desired name or names to include in the plotter.
433461 dark_mode : bool, default: False
434462 Whether to use dark mode for the widgets.
435- plotting_options : dict, default: None
436- Keyword arguments. For allowable keyword arguments, see the
437- :meth:`Plotter.add_mesh <pyvista.Plotter.add_mesh>` method.
438- **show_options : Any
463+ **kwargs : Any
439464 Additional keyword arguments for the show method.
440465
441466 Returns
@@ -444,6 +469,14 @@ def show(
444469 List with the picked bodies in the picked order.
445470
446471 """
472+ plotting_options = self .__extract_kwargs (
473+ self ._pl ._scene .add_mesh ,
474+ kwargs ,
475+ )
476+ show_options = self .__extract_kwargs (
477+ self ._pl .scene .show ,
478+ kwargs ,
479+ )
447480 self .plot (plottable_object , name_filter , ** plotting_options )
448481 if self ._pl .object_to_actors_map :
449482 self ._object_to_actors_map = self ._pl .object_to_actors_map
@@ -479,6 +512,8 @@ def show(
479512 # Update all buttons/widgets
480513 [widget .update () for widget in self ._widgets ]
481514
515+ # Remove screenshot from show options since we pass it manually
516+ show_options .pop ("screenshot" , None )
482517 self .show_plotter (screenshot , ** show_options )
483518
484519 picked_objects_list = []
0 commit comments