Filterable Popup Buttons

Filterable popup buttons are buttons that open filterable popups when clicked.

Class Inheritance

UI4.Widgets.CameraPickerButton

class UI4.Widgets.CameraPickerButton

Bases: QT4Widgets.FilterablePopupButton.FilterablePopupButton

Class implementing a filterable popup button used for the selection of a light or camera from a list of available lights and cameras.

The display mode can be set to one of the following values:
  • DISPLAY_CAMERAS - Displays cameras only.

  • DISPLAY_LIGHTS - Displays lights only.

  • DISPLAY_CAMERAS | DISPLAY_LIGHTS - Displays cameras and lights.

When using DISPLAY_CAMERAS | DISPLAY_LIGHTS for display mode, the button’s label is displayed without a scene graph icon. This mode is used for the main camera/light selection in the Viewer tab, for example.

Variables
  • DISPLAY_CAMERAS – Display mode for displaying cameras.

  • DISPLAY_LIGHTS – Display mode for displaying lights.

  • __builtins – A list of names of viewer cameras provided. Can be extended by calling the addBuiltin() function.

Code example:

cameraPickerButton = UI4.Widgets.CameraPickerButton()
cameraPickerButton.show()

Example Screenshot:

Screenshot of a CameraPickerButton widget

DISPLAY_CAMERAS = 1
DISPLAY_LIGHTS = 2
__init__(parent=None, flat=True, showIcon=False, specialItems=None, showBuiltIns=True, abbreviateNames=True)

Initializes an instance of the class.

Parameters
  • parent (QtWidgets.QWidget or None) – The widget that the new widget will become a child of, or None if the new widget should be owned by PyQt instead of Qt.

  • flat (bool) – Flag to control whether to give the button a flat appearance.

  • showIcon (bool) – Flag to control whether to display a dropdown icon next to the button’s label.

  • specialItems (list or None) – A list of items to always display in the popup, regardless of current display mode or filter settings. A special item is a tuple of (text, pixmap), where text is a str to use as the item label and pixmap is a QtGui.QPixmap to use for the item or None.

  • showBuiltIns (bool) – Flag to control whether to include names of built- in cameras in the list of available cameras and lights in the popup.

  • abbreviateNames (bool) – Flag to control whether to display locations of cameras and lights with abbreviated names instead of their full scene graph location names.

addBuiltin(name)

Adds a built-in camera to the list of cameras in the popup, like "persp", "top", "left", "front" etc.

Parameters

name (str) – The name of the camera to add to the list of cameras in the popup.

clearBuiltins()

Empties the list of built-in cameras.

dragEnterEvent(event)

Event handler for widget drag enter events which are passed in the event parameter. Is called when a drag is in progress and the mouse enters the widget.

If the event is ignored, the widget won’t receive any drag move events.

Parameters

event (QtGui.QDragEnterEvent) – The object that describes the event.

dropEvent(event)

Event handler for widget drop events which are passed in the event parameter. Is called when the drag is dropped on the widget.

Parameters

event (QtGui.QDropEvent) – The object that describes the event.

getBuiltInCameraPath(cameraName)

Converts a displayed camera name into the format that is passed to the viewer when the camera is chosen.

getBuiltInNameFromPath(cameraPath)

Converts a camera path into the original camera name. This is the reverse operation of getBuiltInCameraPath.

getBuiltIns()

Returns the list of build-in camera names.

lookThrough
on_aboutToShow()

Slot that is called when the popup for the camera picker button is about to be opened.

Rebuilds the list of available items in the popup.

on_checkbox_stateChanged(state)

Slot that is called when the B{Lights} or B{Cameras} check box’s state changes, i.e. whenever the user checks or unchecks it.

Rebuilds the list of available items in the popup.

Parameters

state (QtCore.Qt.CheckState) – The state of checkable items, controls, and widgets.

on_itemChosen(value, meta)

Slot that is called when an item in the popup is chosen.

Parameters
  • value (str) – The label of the item that was chosen.

  • meta (tuple) – A tuple containing the camera or light path and the type of the item that was chosen.

on_validateLocationsCheckbox_stateChanged(state)

Slot that is called when the Validate Locations check box’s state changes, i.e. whenever the user checks or unchecks it.

Sets the validation state and rebuilds the list of available items in the popup.

Parameters

state (QtCore.Qt.CheckState) – The state of checkable items, controls, and widgets.

populate()

Rebuilds the list of available items in the popup.

setCameraPath(path)

Sets the camera or light path for the camera picker button to the given value.

Parameters

path (str) – The camera or light path to set for the camera picker button.

setDisplayMode(displayMode)

Sets the display mode of the camera picker button to the given value.

Parameters

displayMode (int) – The display mode to set for the camera picker button.

setScenegraphPixmap(pixmap)

Sets the icon displayed next to the button’s text to the given pixmap.

Parameters

pixmap (QtGui.QPixmap or None) – The pixmap to use as the button’s icon.