コード例 #1
0
ファイル: viz_tab.py プロジェクト: pietroastolfi/fury
create Tabs for:

1. Slider controls for a Cube
2. Checkboxes for Cylinder and Sphere
3. Color combobox for Fury.

First, some imports.
"""
from fury import ui, window, actor
import numpy as np

###############################################################################
# First, we create the Tab UI.

tab_ui = ui.TabUI(position=(49, 94),
                  size=(300, 300),
                  nb_tabs=3,
                  draggable=True)

###############################################################################
# Slider Controls for a Cube for Tab Index 0
# ==========================================
#
# Now we prepare content for the first tab.

ring_slider = ui.RingSlider2D(initial_value=0, text_template="{angle:5.1f}°")

line_slider_x = ui.LineSlider2D(initial_value=0,
                                min_value=-10,
                                max_value=10,
                                orientation="horizontal",
                                text_alignment="Top")
コード例 #2
0
ファイル: test_containers.py プロジェクト: m-agour/fury
def test_ui_tab_ui(interactive=False):
    filename = "test_ui_tab_ui"
    recording_filename = pjoin(DATA_DIR, filename + ".log.gz")
    expected_events_counts_filename = pjoin(DATA_DIR, filename + ".json")

    tab_ui = ui.TabUI(position=(50, 50),
                      size=(300, 300),
                      nb_tabs=3,
                      draggable=True)

    tab_ui.tabs[0].title = "Tab 1"
    tab_ui.tabs[1].title = "Tab 2"
    tab_ui.tabs[2].title = "Tab 3"

    tab_ui.add_element(0, ui.Checkbox(["Option 1", "Option 2"]), (0.5, 0.5))
    tab_ui.add_element(1, ui.LineSlider2D(), (0.0, 0.5))
    tab_ui.add_element(2, ui.TextBlock2D(), (0.5, 0.5))

    with npt.assert_raises(IndexError):
        tab_ui.add_element(3, ui.TextBlock2D(), (0.5, 0.5, 0.5))

    with npt.assert_raises(IndexError):
        tab_ui.remove_element(3, ui.TextBlock2D())

    with npt.assert_raises(IndexError):
        tab_ui.update_element(3, ui.TextBlock2D(), (0.5, 0.5, 0.5))

    npt.assert_equal("Tab 1", tab_ui.tabs[0].title)
    npt.assert_equal("Tab 2", tab_ui.tabs[1].title)
    npt.assert_equal("Tab 3", tab_ui.tabs[2].title)

    npt.assert_equal(3, tab_ui.nb_tabs)

    collapses = itertools.count()
    changes = itertools.count()

    def collapse(tab_ui):
        if tab_ui.collapsed:
            next(collapses)

    def tab_change(tab_ui):
        next(changes)

    tab_ui.on_change = tab_change
    tab_ui.on_collapse = collapse

    event_counter = EventCounter()
    event_counter.monitor(tab_ui)

    current_size = (800, 800)
    show_manager = window.ShowManager(size=current_size, title="Tab UI Test")
    show_manager.scene.add(tab_ui)

    if interactive:
        show_manager.record_events_to_file(recording_filename)
        print(list(event_counter.events_counts.items()))
        event_counter.save(expected_events_counts_filename)
    else:
        show_manager.play_events_from_file(recording_filename)
        expected = EventCounter.load(expected_events_counts_filename)
        event_counter.check_counts(expected)

    npt.assert_equal(0, tab_ui.active_tab_idx)
    npt.assert_equal(11, next(changes))
    npt.assert_equal(5, next(collapses))
コード例 #3
0
ファイル: tab_test.py プロジェクト: Nibba2018/testing-fury
from fury import ui, window

tab_ui = ui.TabUI(position=(300, 300), size=(200, 200), nb_tabs=3)

showm = window.ShowManager(title="Tab Test")
showm.scene.add(tab_ui)
showm.start()