3
$\begingroup$

How to hide panels with python? I want to make quick hiding for better viewing.

Here is what I want to hide:

enter image description here

$\endgroup$

3 Answers 3

6
$\begingroup$

Currently 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)
$\endgroup$
2
  • 1
    $\begingroup$ no way to know if one is open or closed ? $\endgroup$
    – Fox
    Jun 10, 2019 at 20:15
  • $\begingroup$ Added an answer to test if they are already open or not. $\endgroup$
    – Way2Close
    Jun 18, 2019 at 20:01
0
$\begingroup$

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
$\endgroup$
-5
$\begingroup$

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...

$\endgroup$
4
  • 1
    $\begingroup$ I need to do it with python! Not shortcuts. $\endgroup$
    – mifth
    Jan 26, 2015 at 13:07
  • $\begingroup$ Why? Are you making a addon or something? Otherwise I don't see point of it... $\endgroup$ Jan 26, 2015 at 13:37
  • 6
    $\begingroup$ @AdriansNetlis Probably an addon yes, you can suggest alternatives but he asked for a way with python whether you see the point or not. $\endgroup$
    – iKlsR
    Jan 26, 2015 at 13:44
  • $\begingroup$ I know it's been 5 years, but you can enter full screen mode (ctrl+alt+space), I'm am looking for a way to do this from python, but I think that doable $\endgroup$
    – DrDress
    Jan 7, 2021 at 9:08

You must log in to answer this question.

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