![]() |
Shotgun Python ConsoleA Python console for Shotgun Toolkit |

Documentation
Panel
Tabs
Editor
Output
Buttons
Output
Editor
Globals
External sources
Hotkeys
Other notes
Installation, Updates and Development
Configuration Options
Release Notes History
This application provides an interactive python console for any environment that runs Toolkit applications.
Documentation
This is a python console panel for use in DCCs with access to a python interpreter that have limited or no support for interacting with said interpreter.
Python Console in Photoshop CC 2017
Python Console in Flame
Panel
Once installed, the console is registered as a panel in the DCC and is available in the Shotgun menu. In apps that support embedded Toolkit panels (maya, nuke, houdini), the console will display in a docked panel. When using with older versions of these DCCs or in a DCC that does not support panels, the console will simply be shown as a regular Toolkit dialog.
Tabs
The python console displays one or more tabs, each containing an editor and an
output window. New tabs can be created by clicking the +
button in the bottom
right hand corner. Tabs have an x
button next to the tab name that allow you
to delete the tab. Double clicking the tab itself will prompt you to enter a
new name for the tab. Tabs can be rearranged via drag and drop. The state of the
tabs is saved when the DCC is closed and restored on the next launch.
Editor
The console has an input area for editing python. The editor includes line numbers, highlights the cursor's current line, and does some basic syntax highlighting. The console attempts to use the palette of the DCC to give it an integrated look and feel.
Output
The output area displays the results of the executed python. Echoing the source
python commands is turned on by default and is differentiated in the output by
being prefixed with >>>
. Each execution is also marked with a timestamp. There
is a toggle for turning the echo off. Syntax and Runtime errors are shown in red
with a full stack trace for debugging.
Buttons
Output
- Clear - Clear the contents of the output browser.
- Echo - Toggle echoing the executed commands in the output browser.
Editor
- Execute - Execute the contents of the editor
- Save - Save the current contents of the editor to a file.
- Open - Open a file in the editor.
- Clear - Clear the contents of the editor.
- Lines - Toggle line numbers for the current tab
Globals
Some Shotgun/Toolkit globals are pre-defined in the console, similar to what is available in the Shotgun Engine for the shell.
- Tk API handle is available via the
tk
variable - Shotgun API handle is available via the
shotgun
variable - The current context is stored in the
context
variable - The shell engine can be accessed via the
engine
variable
External sources
The app comes with a hook that can be implemented to load python source from an
external location. The hook is called external_sources_hook
and requires
implementing a method called get_external_source_actions
. The method should
return a list of QActions
that, when triggered, add a new tab (with content)
to the console. An example implementation is provided that loads gists from
github for a list of predefined users. The actions returned by the hook are
shown in the popup menu displayed when the Open button is pressed and held.
Hotkeys
- Execute selected with
Ctrl + Enter
- Create a new tab with
Ctrl + T
- Navigate tabs with
Ctrl + Shift + [
orCtrl + Shift + ]
- Resize input/output font via
Ctrl + Wheel
NOTE: These hotkeys may not be available in all DCCs.
Other notes
- In some older versions of DCCs, leaving the python console open when closing the session may cause a crash. We believe this may be a bug in some older versions of PySide. More recent versions of DCCs, bundled with newer versions of PySide, do not appear to crash on exit. If you encounter this issue with a recent DCC release, please submit a ticket so that we can investigate further.
Installation and Updates
Adding this App to the Shotgun Pipeline Toolkit
If you want to add this app to Project XYZ, in an environment named asset, execute the following command:
> tank Project XYZ install_app asset tk-maya tk-multi-pythonconsole
Updating to the latest version
If you already have this item installed in a project and you want to get the latest
version, you can run the update
command. You can either navigate to the
tank command that comes with that specific project, and run it there:
> cd /my_tank_configs/project_xyz > ./tank updates
Alternatively, you can run your studio tank
command and specify the project
name to tell it which project to run the update check for:
> tank Project XYZ updates
Collaboration and Evolution
![]() |
If you have access to the Shotgun Pipeline Toolkit, you also have access to the source code for all apps, engines and frameworks in Github where we store and manage them. Feel free to evolve these items; use them as a base for further independent development, make changes (and submit pull requests back to us!) or simply tinker with them to see how they have been built and how the toolkit works. You can access this code repository at https://github.com/shotgunsoftware/tk-multi-pythonconsole. |
Special Requirements
- You need Shotgun version v6.2.0 or higher to use this.
- You need Shotgun Pipeline Toolkit Core API version v0.16.32 or higher to use this.
Configuration
Below is a summary of all the configuration settings used. These settings need to be defined in the environment file where you want to enable this App or Engine.
external_sources_hook
Type: hook
Default Value: {self}/external_sources.py
Description: Supplies information about external sources for new tabs.
Release Notes
Welcome to the release notes for this App. Below you will find an overview of all the changes we did for each release. We try to be as detailed as possible and include all bugs we have fixed, features we have added and things that may have changed. If you have questions about a particular release, don't hesitate to contact our support team!
v1.1.2
2018-Mar-14
Bug fix
v1.1.1
2017-Aug-18
Changes to allow the app to run independently of toolkit
v1.1.0
2017-May-16
Moves the python console menu item from the main menu to the context menu.
v1.0.9
2017-Mar-15
Removes problematic profiles from png files used as icons.
Details:
This will silence libpng warnings from Qt when the png files are loaded as pixmaps. This is a second attempt as this profile stripping, and uses ImageMagick's "mogrify" command to achieve the desired result, which maintains color consistency.
v1.0.7
2017-Feb-08
Use active window for dialog parenting
v1.0.6
2017-Feb-08
Bug fix for both echo output and show lines toggles
v1.0.5
2017-Feb-07
QA fixes for toggle echo and line numbers
v1.0.4
2017-Feb-07
QA fixes for dialog parenting
v1.0.3
2017-Feb-07
Removed unnecessary minimum width
v1.0.2
2017-Feb-07
Do not use native file dialogs. Fixes issues in photoshopcc engine
v1.0.1
2017-Feb-07
Updated docs, external sources hook is no-op by default
v1.0.0
2017-Feb-06
QA fixes
v0.0.3
2016-Jul-13
Bug fixes, tabs, external resources, and more
v0.0.2
2016-Jun-29
bug fixes, tabs, external resources, and more
v0.0.1
Initial release
7 Comments