10
$\begingroup$

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.

$\endgroup$
7
  • $\begingroup$ This isn't currently exposed to the API (but we can if its useful), can you explain why you would want to access this? $\endgroup$
    – ideasman42
    Feb 3, 2014 at 10:47
  • 2
    $\begingroup$ @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). $\endgroup$ Feb 3, 2014 at 15:35
  • $\begingroup$ 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. $\endgroup$
    – CodeManX
    Feb 4, 2014 at 2:32
  • 1
    $\begingroup$ @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? $\endgroup$
    – aliasguru
    Oct 13, 2016 at 19:54
  • $\begingroup$ I'd also like to know about how this progressed, if at all. $\endgroup$ Nov 5, 2016 at 7:29

2 Answers 2

4
$\begingroup$

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

$\endgroup$
2
$\begingroup$

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'

:)

$\endgroup$
1
  • 6
    $\begingroup$ 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] $\endgroup$
    – CodeManX
    Aug 26, 2014 at 12:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .