pyvista / pyvista-support

[moved] Please head over to the Discussions tab of the PyVista repository
https://github.com/pyvista/pyvista/discussions
59 stars 4 forks source link

custom slider parameters #520

Closed rc closed 2 years ago

rc commented 2 years ago

Description

Hi!

With a previous version of pyvista, I have used custom slider parameters as follows:

import pyvista as pv

pv.rcParams['slider_style'].update({
    'custom': {
        'slider_length': 0.02,
        'slider_width': 0.02,
        'slider_color': (0.42, 0.42, 0.42),
        'tube_width': 0.01,
        'tube_color': (0.7, 0.7, 0.7),
        'cap_opacity': 0,
        'cap_length': 0.01,
        'cap_width': 0.02},
    }
)

pvax.add_slider_widget(..., style='custom')

I have found that in the current pyvista (0.32.1) this no longer works and that one cannot add a new style(?) I came up with a workaround by redefining the 'modern' style:

pv.global_theme['slider_styles'] = pv.global_theme['slider_styles'].from_dict({
    'modern': {
        'slider_length': 0.02,
        'slider_width': 0.02,
        'slider_color': (0.42, 0.42, 0.42),
        'tube_width': 0.01,
        'tube_color': (0.7, 0.7, 0.7),
        'cap_opacity': 0,
        'cap_length': 0.01,
        'cap_width': 0.02},
    }
)

pvax.add_slider_widget(..., style='modern')

Is my approach correct, or is there and easier/better way (like the original dict update)?

Thank you! r.