Context Selector Widget

This widget is a standardized context selection UI, suitable to be dropped in when a Toolkit App needs a user to select a context:


The widget includes the following features:

  • Uses standard auto completers to allow a user to quickly find tasks or links.
  • Keeps recently selected tasks on the menu for quick lookup.
  • Shows related tasks for a given task or link.
  • Configurable to be just a viewer rather than a selector.
  • Configurable title
class context_selector.ContextWidget(parent)[source]

Widget which represents the current context and allows the user to search for a different context via search completer. A menu is also provided for recent contexts as well as tasks assigned to the user.

Signal context_changed(context_obj):
 Fires when when the user selects a context.
Parameters:parent (QObject) – The model parent.

Should be called by the parent widget, typically when the dialog closes, to ensure the recent contexts are saved to disk when closing.

set_context(context, task_display_override=None, link_display_override=None)[source]

Set the context to display in the widget.

The initial display values can be overridden via the task and link override args.

  • context – Toolkit Context that the widget should be set to.
  • task_display_override (str) – Override text to be displayed for the task.
  • link_display_override (str) – Override text to be displayed for the link.

Handles initial set up of the widget. Includes setting up menu, running any background set up tasks, etc.

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

Specify what entries should show up in the list of links when using the auto completer.

For the simple case where you just want to show a given set of entity types, use restrict_entity_types(). This method is a more complex restriction suitable for workflows around publishing and review.

This method will look at the given link field (e.g. PublishedFile.entity) and inspect the shotgun schema to see which entity types are valid connections to this field (e.g. in this example which entity types can you can associate a publish with) and those types will appear in the list of items shown by the auto completer.

This is useful when you want to use the context widget in conjunction with workflows related to for example publishes, versions or notes and you want to restrict the entities displayed by the auto completer to the ones that have been configured in the shotgun site schema to be able to associate with the given type.

  • entity_type (str) – Entity type to restrict based on
  • field_name (str) – Shotgun field to restrict based on

Restrict which entity types should show up in the list of matches.

Parameters:entity_types (list) – List of entity types

The label for the context widget.


Specify a string (can be html) which should be shown as the tooltip for the task selection widget

Parameters:tooltip (str) – Tooltip plaintext or html

Specify a string (can be html) which should be shown as the tooltip for the link selection widget

Parameters:tooltip (str) – Tooltip plaintext or html
enable_editing(enabled, message=None)[source]

Show/hide the input widgets and display a message in the context label.

  • enabled (bool) – Indicates if task/link selectors should be shown
  • message (str) – Message to display on context_label()