Shotgun Search Widget

The Shotgun search widgets are similar to the global search and hierarchical search found in Shotgun. They return a number of matches based on text that is being typed in by the user.

_images/global_search.png

Once a user selects an object, a signal fires to indicate the request.

class shotgun_search_widget.GlobalSearchWidget(parent)[source]

A QT Widget deriving from QLineEdit that creates a global search input box with auto completion.

Signal:entity_selected(str, int) - 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 selects an entity inside the search results. Similar to entity_selected, with the addition of the name of the activated entity being supplied.

Uses the GlobalSearchCompleter as the completer for searching SG entities.

Parameters:parent (QWidget) – Qt parent object
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.

See the documentation for GlobalSearchCompleter.set_searchable_entity_types for the default values if this method is not called on the widget.

Parameters:types_dict – A dictionary of searchable types with optional filters
clear()

Clears the search box.

destroy()

Should be called before the widget is closed.

keyPressEvent(event)

Clears the line edit when the user hits escape.

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
set_placeholder_text(text)

Set the placeholder text for the widget

Parameters:text – The text to use
class shotgun_search_widget.HierarchicalSearchWidget(parent)[source]

A QT Widget deriving from QLineEdit that creates a hierarchical search input box with auto completion.

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_paths. If the node activated is not an entity, type and id will be None.

Uses the HierarchicalSearchCompleter as the completer for searching SG entities.

Parameters:parent (QWidget) – Qt parent object
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.

clear()

Clears the search box.

destroy()

Should be called before the widget is closed.

keyPressEvent(event)

Clears the line edit when the user hits escape.

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
set_placeholder_text(text)

Set the placeholder text for the widget

Parameters:text – The text to use
seed_entity_field

The seed entity to use when searching for entity.

Can be PublishedFile.entity or Version.entity.