.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/07_ui/viz_spinbox.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_07_ui_viz_spinbox.py: =========== SpinBox UI =========== This example shows how to use the UI API. We will demonstrate how to create a SpinBox UI. First, some imports. .. GENERATED FROM PYTHON SOURCE LINES 12-17 .. code-block:: Python import numpy as np import fury .. GENERATED FROM PYTHON SOURCE LINES 18-19 First we need to fetch some icons that are included in FURY. .. GENERATED FROM PYTHON SOURCE LINES 19-22 .. code-block:: Python fury.data.fetch_viz_icons() .. GENERATED FROM PYTHON SOURCE LINES 23-24 Let's create a Cone. .. GENERATED FROM PYTHON SOURCE LINES 24-32 .. code-block:: Python cone = fury.actor.cone( centers=np.random.rand(1, 3), directions=np.random.rand(1, 3), colors=(1, 1, 1), heights=np.random.rand(1), ) .. GENERATED FROM PYTHON SOURCE LINES 33-34 Creating the SpinBox UI. .. GENERATED FROM PYTHON SOURCE LINES 34-44 .. code-block:: Python spinbox = fury.ui.SpinBox( position=(200, 100), size=(300, 100), min_val=0, max_val=360, initial_val=180, step=10, ) .. GENERATED FROM PYTHON SOURCE LINES 45-47 Now that all the elements have been initialised, we add them to the show manager. .. GENERATED FROM PYTHON SOURCE LINES 47-54 .. code-block:: Python current_size = (800, 800) show_manager = fury.window.ShowManager(size=current_size, title="FURY SpinBox Example") show_manager.scene.add(cone) show_manager.scene.add(spinbox) .. GENERATED FROM PYTHON SOURCE LINES 55-56 Using the on_change hook to rotate the cone. .. GENERATED FROM PYTHON SOURCE LINES 56-70 .. code-block:: Python # Tracking previous value to check in/decrement. previous_value = spinbox.value def rotate_cone(spinbox): global previous_value change_in_value = spinbox.value - previous_value fury.utils.rotate(cone, (change_in_value, 1, 0, 0)) previous_value = spinbox.value spinbox.on_change = rotate_cone .. GENERATED FROM PYTHON SOURCE LINES 71-72 Starting the ShowManager. .. GENERATED FROM PYTHON SOURCE LINES 72-81 .. code-block:: Python interactive = False if interactive: show_manager.start() fury.window.record( scene=show_manager.scene, size=current_size, out_path="viz_spinbox.png" ) .. _sphx_glr_download_auto_examples_07_ui_viz_spinbox.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: viz_spinbox.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: viz_spinbox.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: viz_spinbox.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_