# Get current editor toolbar tab via Python?

How can I detect and/or change the active tab in the current editor via Python?

Is this doable? I have been digging through bpy.context.region/screen and not yet found a way to list the active tab.

• This isn't currently exposed to the API (but we can if its useful), can you explain why you would want to access this? – ideasman42 Feb 3 '14 at 10:47
• @ideasman42 I'd like to expose it in the API so as to add hotkeys for switching tabs. This has been a commonly requested feature and something that I would like to play with in Python. This could also allow some more advanced functionality, like automatic tab switching for specific addons or tasks (not so sure on this one, but could be interesting to play with). – Jonathan Williamson Feb 3 '14 at 15:35
• Hotkeys to switch tabs sounds good to me (no one can moan if it's an addon), but scripters could abuse it to make their addons show on activation or during certain actions - two of such addons and it could end in an annoying loop. Nonetheless, it should be exposed, since there are little security checks overall in Blender and official addons are controlled. – CoDEmanX Feb 4 '14 at 2:32
• @CoDEmanX It's been a while since this question was raised, but has this been tried / implemented by the devs in the past two years? Or were the concerns regarding Guerilla Addons causing loops too big? – aliasguru Oct 13 '16 at 19:54
• I'd also like to know about how this progressed, if at all. – Derek Watts Nov 5 '16 at 7:29

This isn't currently exposed to the API (but we can expose it if it's useful).

If you mean that you want to turn, let's say, your current editor to the UV Image Editor, you could use the following code:

bpy.context.area.type = 'IMAGE_EDITOR'


Here are the rest of the strings you put for different screens:

3D Object Editor - 'VIEW_3D'
Timeline editor - 'TIMELINE'
Graph Editor - 'GRAPH_EDITOR'
Dopesheet Editor - 'DOPESHEET_EDITOR'
NLA Editor - 'NLA_EDITOR'
UV Image Editor - 'IMAGE_EDITOR'
Sequence Editor - 'SEQUENCE_EDITOR'
Clip Editor - 'CLIP_EDITOR'
Text Editor - 'TEXT_EDITOR'
Node Editor - 'NODE_EDITOR'
Game Logic Editor - 'LOGIC_EDITOR'
Properties Panel - 'PROPERTIES_EDITOR'
Outliner - 'OUTLINER'
User Preferences Screen - 'USER_PREFERENCES'
Info Panel - 'INFO'
File Browser - 'FILE_BROWSER'
Python Console - 'CONSOLE'


(The colours above don't mean anything)

So if you want to switch to the file browser, you would do:

bpy.context.area.type = 'FILE_BROWSER'


:)

• You can get a list with description with this one-liner: [(item.identifier, item.name, item.description) for item in bpy.types.Area.bl_rna.properties['type'].enum_items] – CoDEmanX Aug 26 '14 at 12:36