Shotgun Search Completers

Global Search Completer

The global search completer is a QCompleter instance for use with widgets that allow input of Shotgun entities. The completer can be customized to search across a given set of entity types.

Once a user selects an object, a signal fires to indicate that an entity was activated.

class search_completer.GlobalSearchCompleter(parent=None)[source]

A standalone PySide.QtGui.QCompleter class for matching SG entities to typed text.

Signal:entity_selected(str, int) - Provided for backward compatibility. entity_activated is emitted at the same time with an additional name value. Fires when someone selects an entity inside the search results. The returned parameters are entity type and entity id.
Signal:entity_activated(str, int, str) - Fires when someone activates an entity inside the search results. Essentially the same as entity_selected only the parameters returned are type, id and name.
Modes:MODE_LOADING, MODE_NOT_FOUND, MODE_RESULT - Used to identify the mode of an item in the completion list
Model role:MODE_ROLE - Stores the mode of an item in the completion list (see modes above)
Model role:SG_DATA_ROLE - Role for storing shotgun data in the model
Parameters:parent (QWidget) – Parent widget
get_result(model_index)[source]

Return the entity data for the supplied model index or None if there is no data for the supplied index.

Parameters:model_index (QModelIndex) – The index of the model to return the result for.
Returns:The entity dict for the supplied model index.
Return type:dict: or None
set_searchable_entity_types(types_dict)[source]

Specify a dictionary of entity types with optional search filters to limit the breadth of the widget’s search.

Use this method to override the default searchable entity types dictionary which looks like this:

{
  "Asset": [],
  "Shot": [],
  "Task": [],
  "HumanUser": [["sg_status_list", "is", "act"]],    # only active users
  "Group": [],
  "ClientUser": [["sg_status_list", "is", "act"]],   # only active users
  "ApiUser": [],
  "Version": [],
  "PublishedFile": [],
}
Parameters:types_dict – A dictionary of searchable types with optional filters
clear()

Manually clear the contents of the completer’s popup view.

destroy()

Should be called before the widget is closed

get_current_result()

Returns the result from the current item in the completer popup or None if there is no current item.

Returns:The entity dict for the current result
Return type:dict: or None
get_first_result()

Returns the first result from the current item in the completer popup or None if there are no results.

Returns:The entity dict for the first result
Return type:dict: or None
search(text)

Triggers the popup to display results based on the supplied text.

Parameters:text – current contents of editor
set_bg_task_manager(task_manager)

Specify the background task manager to use to pull data in the background. Data calls to Shotgun will be dispatched via this object.

Parameters:task_manager (BackgroundTaskManager) – Background task manager to use

Hierarchical Search Completer

The hierarchical search completer is a QCompleter instance for use with widgets that allow input of Shotgun entities. The completer can be customized to search in a site’s complete hierarchy or in a single project.

Once a user selects an object, a signal fires to indicate that a node from the hierarchy was selected.

class search_completer.HierarchicalSearchCompleter(parent=None)[source]

A standalone PySide.QtGui.QCompleter class for matching SG entities to typed text.

If defaults to searching inside the current context’s project and to only show entities.

Signal:node_activated(str, int, str, str, list) - Fires when someone activates a node inside the search results. The parameters are type, id, name, label_path and incremental_path. If the node activated is not an entity, type and id will be None.
Modes:MODE_LOADING, MODE_NOT_FOUND, MODE_RESULT - Used to identify the mode of an item in the completion list
Model role:MODE_ROLE - Stores the mode of an item in the completion list (see modes above)
Model role:SG_DATA_ROLE - Role for storing shotgun data in the model
Parameters:parent (QWidget) – Parent widget
search_root

The entity under which the search will be done. If None, the search will be done for the whole site.

The entity is a dict with keys id and type. Note that only Project entities are supported at the moment.

show_entities_only

Indicates if only entities will be shown in the search results.

If set to True, only entities will be shown.

seed_entity_field

The seed entity to use when searching for entity.

Can be PublishedFile.entity or Version.entity.

clear()

Manually clear the contents of the completer’s popup view.

destroy()

Should be called before the widget is closed

get_current_result()

Returns the result from the current item in the completer popup or None if there is no current item.

Returns:The entity dict for the current result
Return type:dict: or None
get_first_result()

Returns the first result from the current item in the completer popup or None if there are no results.

Returns:The entity dict for the first result
Return type:dict: or None
search(text)

Triggers the popup to display results based on the supplied text.

Parameters:text – current contents of editor
set_bg_task_manager(task_manager)

Specify the background task manager to use to pull data in the background. Data calls to Shotgun will be dispatched via this object.

Parameters:task_manager (BackgroundTaskManager) – Background task manager to use
get_result(model_index)[source]

Returns an item from the result list.

Here’s an example:

{
    "label": "bunny_020",
    "incremental_path": [
        "/Project/65",
        "/Project/65/Shot",
        "/Project/65/Shot/sg_sequence/Sequence/5"
    ],
    "path_label": "Shots",
    "ref": {
        "id": 5,
        "type": "Sequence"
    },
    "project_id": 65
}
Parameters:model_index (QModelIndex) – The index of the model to return the result for.
Returns:The dict for the supplied model index.
Return type:dict or None