How to use the fury.ui.TextBlock2D function in fury

To help you get started, we’ve selected a few fury examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fury-gl / fury / docs / tutorials / 04_others / viz_timers.py View on Github external
scene = window.Scene()

sphere_actor = actor.sphere(centers=xyz,
                            colors=colors,
                            radii=radii)

scene.add(sphere_actor)

showm = window.ShowManager(scene,
                           size=(900, 768), reset_camera=False,
                           order_transparent=True)

showm.initialize()

tb = ui.TextBlock2D(bold=True)

# use itertools to avoid global variables
counter = itertools.count()


def timer_callback(_obj, _event):
    cnt = next(counter)
    tb.message = "Let's count up to 100 and exit :" + str(cnt)
    showm.scene.azimuth(0.05 * cnt)
    sphere_actor.GetProperty().SetOpacity(cnt/100.)
    showm.render()
    if cnt == 100:
        showm.exit()


scene.add(tb)
github fury-gl / fury / docs / tutorials / 03_advanced_ui / viz_ui.py View on Github external
###############################################################################
# Panel with buttons and text
# ===========================
#
# Let's create some buttons and text and put them in a panel. First we'll
# make the panel.

panel = ui.Panel2D(size=(300, 150), color=(1, 1, 1), align="right")
panel.center = (500, 400)

###############################################################################
# Then we'll make two text labels and place them on the panel.
# Note that we specifiy the position with integer numbers of pixels.

text = ui.TextBlock2D(text='Click me')
text2 = ui.TextBlock2D(text='Me too')
panel.add_element(text, (50, 100))
panel.add_element(text2, (180, 100))

###############################################################################
# Then we'll create two buttons and add them to the panel.
#
# Note that here we specify the positions with floats. In this case, these are
# percentages of the panel size.


button_example = ui.Button2D(
    icon_fnames=[('square', read_viz_icons(fname='stop2.png'))])

icon_files = []
icon_files.append(('down', read_viz_icons(fname='circle-down.png')))
github fury-gl / fury / docs / tutorials / 02_ui / viz_buttons.py View on Github external
from fury import ui, window
from fury.data import read_viz_icons

###############################################################################
# Let's create some buttons and text and put them in a panel.
# First we'll make the panel.

panel = ui.Panel2D(size=(300, 150), color=(1, 1, 1), align="right")
panel.center = (500, 400)

###############################################################################
# Then we'll make two text labels and place them on the panel.
# Note that we specifiy the position with integer numbers of pixels.

text = ui.TextBlock2D(text="Click me")
text2 = ui.TextBlock2D(text="Me too")
panel.add_element(text, (50, 100))
panel.add_element(text2, (180, 100))

###############################################################################
# Then we'll create two buttons and add them to the panel.
#
# Note that here we specify the positions with floats. In this case, these are
# percentages of the panel size.


button_example = ui.Button2D(
    icon_fnames=[("square", read_viz_icons(fname="stop2.png"))]
)

icon_files = []
icon_files.append(("down", read_viz_icons(fname="circle-down.png")))
github fury-gl / fury / fury / ui.py View on Github external
def _setup(self):
        """ Setup this UI component.
        """
        # Option's button
        self.button_icons = []
        self.button_icons.append(('unchecked',
                                 read_viz_icons(fname="stop2.png")))
        self.button_icons.append(('checked',
                                 read_viz_icons(fname="checkmark.png")))
        self.button = Button2D(icon_fnames=self.button_icons,
                               size=self.button_size)

        self.text = TextBlock2D(text=self.label, font_size=self.font_size)

        # Add callbacks
        self.button.on_left_mouse_button_clicked = self.toggle
        self.text.on_left_mouse_button_clicked = self.toggle
github fury-gl / fury / docs / tutorials / 04_others / viz_slice.py View on Github external
# on a panel in the window. The panel is a UI element which requires access to
# different areas of the visualization pipeline and therefore we don't
# recommend using it with ``window.show``. The more appropriate way is to use
# the ``ShowManager`` object, which allows accessing the pipeline in different
# areas.

show_m = window.ShowManager(scene, size=(1200, 900))
show_m.initialize()

###############################################################################
# We'll start by creating the panel and adding it to the ``ShowManager``

label_position = ui.TextBlock2D(text='Position:')
label_value = ui.TextBlock2D(text='Value:')

result_position = ui.TextBlock2D(text='')
result_value = ui.TextBlock2D(text='')

panel_picking = ui.Panel2D(size=(250, 125),
                           position=(20, 20),
                           color=(0, 0, 0),
                           opacity=0.75,
                           align="left")

panel_picking.add_element(label_position, (0.1, 0.55))
panel_picking.add_element(label_value, (0.1, 0.25))

panel_picking.add_element(result_position, (0.45, 0.55))
panel_picking.add_element(result_value, (0.45, 0.25))

show_m.scene.add(panel_picking)
github fury-gl / fury / fury / ui.py View on Github external
self.track = Rectangle2D()
        self.track.color = (1, 0, 0)

        # Handles
        self.handles = []
        if self.shape == "disk":
            self.handles.append(Disk2D(outer_radius=1))
            self.handles.append(Disk2D(outer_radius=1))
        elif self.shape == "square":
            self.handles.append(Rectangle2D(size=(1, 1)))
            self.handles.append(Rectangle2D(size=(1, 1)))
        self.handles[0].color = self.default_color
        self.handles[1].color = self.default_color

        # Slider Text
        self.text = [TextBlock2D(justification="center",
                                 vertical_justification="top"),
                     TextBlock2D(justification="center",
                                 vertical_justification="top")
                     ]

        # Add default events listener for this UI component.
        self.track.on_left_mouse_button_dragged = self.handle_move_callback
        self.handles[0].on_left_mouse_button_dragged = \
            self.handle_move_callback
        self.handles[1].on_left_mouse_button_dragged = \
            self.handle_move_callback
        self.handles[0].on_left_mouse_button_released = \
            self.handle_release_callback
        self.handles[1].on_left_mouse_button_released = \
            self.handle_release_callback
github fury-gl / fury / docs / tutorials / 02_ui / viz_ui_listbox.py View on Github external
=========

This example shows how to use the UI API. We will create a list
some geometric shapes from DIPY UI elements.

First, a bunch of imports.
"""
from fury import ui, window

###############################################################################
# Create some text blocks that will be showm when
# list elements will be selected

welcome_text = ui.TextBlock2D(text="Welcome", font_size=30,
                              position=(500, 400))
bye_text = ui.TextBlock2D(text="Bye", font_size=30, position=(500, 400))
fury_text = ui.TextBlock2D(text="Fury", font_size=30, position=(500, 400))

example = [welcome_text, bye_text, fury_text]

###############################################################################
# Hide these text blocks for now


def hide_all_examples():
    for element in example:
        element.set_visibility(False)


hide_all_examples()

###############################################################################