open_viewmin.filter_tree_plot_Qt.widgets_Qt.utilities_Qt

Contents

open_viewmin.filter_tree_plot_Qt.widgets_Qt.utilities_Qt#

Define classes for dialogs and actor control toolbars

Classes#

ColorDialogValid

Qt.QtWidgets.QColorDialog that resets to initial color if canceled.

ControlsSliderToolbar

Control toolbar containing a slider

ControlsToolbar

Toolbar containing controls for visualizing mesh in filters tree

DropdownMenu

Convenience class for creating dropdown menus from push-buttons.

FormDialog

Convenience dialog with form layout inside a box layout.

QDoubleSpinBoxIgnoreLims

PyQt5.QtWidgets.QDoubleSpinBox with auto-updating range

Functions#

add_close_button_to_toolbar(toolbar[, closes, add_padding])

Add button to close a widget

Module Contents#

class ColorDialogValid(callback, initial_color, parent=None)#

Bases: qtpy.QtWidgets.QColorDialog

Qt.QtWidgets.QColorDialog that resets to initial color if canceled.

Parameters:
  • callback (callable()) – Function of the chosen color

  • initial_color ((float, float, float), str, or None) – Color to apply if the user presses “Cancel”

  • parent (QWidget, optional) – Parent widget

color_dialog_callback(chosen_qcolor)#

Send chosen color to callback

Parameters:

chosen_qcolor (PyQt5.QtGui.QColor)

static color_to_qcolor(color)#

Convert various color formats to QColor

Parameters:

color (pyvista.plotting.colors.Color | numpy.ndarray | tuple | str) – For numpy.ndarray or tuple, elements must be int`s, or there can be exactly one element in the form of a hex color string beginning with `”#”. For str, must be a hex color string beginning with “#” or a named color.

Return type:

PyQt5.QtGui.QColor

reset_to_initial_color()#

Reset color to initial_color

callback#
initial_color#
class ControlsSliderToolbar(update_method, actor=None, num_divs=100, init_val_percent=50, max_val=None, min_val=None, scalars=None, label_txt='', name=None, spinbox=True, has_close_button=False)#

Bases: qtpy.QtWidgets.QToolBar

Control toolbar containing a slider

add_close_button()#

Add button that closes (removes) this toolbar

external_update(float_value)#

Externally called trigger for update of slider from given value

Parameters:

float_value (float)

slider_formula(slider_value)#

Convert from slider integer value to formula float value.

spinbox_callback()#

Update slider from spinbox

value_change_method(slider_value)#

Update actor’s visibility and toolbox’s spinbox from slider value

Parameters:

slider_value (int)

wiggle_slider_to_update()#

For an actor with some feature controlled by a slider, move the slider right and left to force the actor to update

QLabel#
actor#
init_val#
max_val#
min_val#
num_divs#
slider#
update_method#
class ControlsToolbar(name=None, label=None, icon_size=None, movable=True, floatable=False, orientation='horizontal', has_close_button=True, has_refresh_button=False)#

Bases: qtpy.QtWidgets.QToolBar

Toolbar containing controls for visualizing mesh in filters tree

Parameters:
  • name (str or None, optional) – Key for toolbar in plotter.toolbars. Defaults to label.

  • label (str or None, optional) – Toolbar title to display. Required if name is None.

  • icon_size (float or None, optional) – Size in pixels of icons such as “close” button.

  • movable (bool, optional) – Whether toolbar order can be rearranged by dragging with mouse.

  • floatable (bool, optional) – Whether toolbar can be detached from its parent widget by dragging with mouse.

  • orientation ("horizontal" or "vertical", optional) – Toolbar orientation.

  • has_close_button (bool, optional) – Whether toolbar has a button that closes itself.

  • has_refresh_button (bool, optional) – Whether toolbar has a button that triggers its refresh_actions.

add_close_button()#

Add button to close a widget

add_refresh_button()#

Add button that triggers refresh

refresh()#

Execute all functions in refresh_actions

set_icon_size(icon_size=None)#
set_label(text=None)#

Change text in label toolbar

QLabel#
horizontal#
icon_size#
label = ''#
label_toolbar#
options_toolbar#
refresh_actions = []#
rows#
class DropdownMenu(width=None)#

Bases: qtpy.QtWidgets.QPushButton

Convenience class for creating dropdown menus from push-buttons.

Parameters:

width (float or None, optional) – Width of push-button

populate(label_callback_pairs)#

Fill menu with actions

Parameters:

label_callback_pairs (Iterable of tuple(str, callable))

set_button_text()#

Set text of button that triggers dropdown

menu#
class FormDialog(title='', message=None, parent=None, apply_button=False, **kwargs)#

Bases: qtpy.QtWidgets.QDialog

Convenience dialog with form layout inside a box layout.

Parameters:
  • title (str, optional) – Dialog widget title.

  • message (str or None, optional) – Text displayed at top of dialog.

  • parent (qtpy.QtWidgets.QWidget or None, optional)

  • apply_button (bool, optional) – Whether to place “Apply” button alongside “OK” and “Cancel” buttons.

  • **kwargs (dict, optional) – Keyword arguments to qtpy.QtWidgets.QDialog

Examples

>>> form_dialog = FormDialog(
...    title="This is a FormDialog",
...    message="This is an example FormDialog. Please choose an integer."
... )
>>>
>>> spinbox = qtpy.QtWidgets.QSpinBox()
>>> form_dialog.add_row("Choose an integer:", spinbox)
>>>
>>> def ok_callback():
...     print(f"You chose {spinbox.value()}")
>>>
>>> form_dialog.set_accepted_callback(ok_callback)
>>> form_dialog.show()
add_row(text, input_widget)#
Parameters:
  • text (str)

  • input_widget (qtpy.QtWidgets.QWidget)

Return type:

qtpy.QtWidgets.QWidget

set_accepted_callback(callback)#

Connect function to “OK” button

Parameters:

callback (callable)

set_rejected_callback(callback)#

Connect function to “Cancel” button

Parameters:

callback (callable)

show()#
buttonBox#
formlayout#
layout#
class QDoubleSpinBoxIgnoreLims(*args, num_subdivisions=1000, **kwargs)#

Bases: qtpy.QtWidgets.QDoubleSpinBox

PyQt5.QtWidgets.QDoubleSpinBox with auto-updating range

Values entered outside the current allowed range cause the max or min value to be shifted to accommodate.

Parameters:
  • *args (tuple, optional) – Arguments to PyQt5.QtWidgets.QDoubleSpinBox

  • num_subdivisions (int, optional) – Number of subdivisions of the range, determining the step size.

  • **kwargs (dict, optional) – Keyword arguments to PyQt5.QtWidgets.QDoubleSpinBox

qslider_value()#

Slider position to match current value

Return type:

int

set_high_val(value)#

Set reference high value.

Sufficiently high value triggers increase in maximum.

Parameters:

value (float)

set_low_val(value)#

Set reference low value.

Sufficiently low value triggers decrease in minimum.

Parameters:

value (float)

set_value_from_qslider(qslider_value)#

Set value according to associated slider

Parameters:

qslider_value (int)

update_single_step()#

Change increment to reflect change in extent

property extent#
Difference between reference high and low values.
Return type:

float

high_val#
low_val#
num_subdivisions#
add_close_button_to_toolbar(toolbar, closes=None, add_padding=False)#

Add button to close a widget

Parameters:
  • toolbar (qtpy.QtWidgets.QToolBar) – Toolbar to which button will be added

  • closes (qtpy.QtWidgets.QWidget or None, optional) – Widget closed by button. Defaults to toolbar

  • add_padding (bool, optional) – Whether to place the button on the right side of the toolbar

Returns:

The created “close” button

Return type:

qtpy.QtWidgets.QToolButton