How to hide panels with python? I want to make quick hiding for better viewing.
Here is what I want to hide:
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.
Sign up to join this communityCurrently the Python API can't handle opening and closing panels (it's not exposed).
Related: Is it possible to expand/collapes all panels in a region with a keystroke or shortcut?
The only thing you can do with python is to toggle by calling operators:
bpy.ops.view3d.properties()
bpy.ops.view3d.toolshelf()
They need the right context though, so they need to be called from the 3dview area or the context needs to be overwritten. This will toggle all panels in all 3d_views inside window:
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
context_copy = bpy.context.copy()
context_copy['area'] = area
bpy.ops.view3d.properties(context_copy)
bpy.ops.view3d.toolshelf(context_copy)
Here is a way to check if they are currently open, you simply test how wide they are, also suggest storing a variable if you intend to untoggle it "toggle_properties = True" for a modal so you don't have to test again.
# hide 'T' and 'N' panels
for r in bpy.context.area.regions:
if r.type == 'UI':
if r.width > 1:
bpy.ops.view3d.properties()
toggle_properties = True
elif r.type == 'TOOLS':
if r.width > 1:
bpy.ops.view3d.toolshelf()
toggle_tools = True
You don't need python to quickly hide. Just make sure your mouse is in 3D view zone and press N to hide/unhide right panel and T to hide/unhide left panel. But, if you need full 3D view, you can select that layout on the top...