Searching for a solution to

When using blender 2.8x on an old 4x3 monitor the workspace tabs get shifted too far right and its a handy option to collapse the menus.

enter image description here

For most, if not all, other area headers, this can be achieved by collapsing menus and saving the start up file.

For other editor types it can also be toggled via script by finding all header regions and passing that area via a context override to header toggle menus op

import bpy

for a in bpy.context.screen.areas:
    bpy.ops.screen.header_toggle_menus({"area" : a})

to toggle menus in headers of all areas in screen. Or as pointed out by @Leander can set the area property directly

    a.show_menus = False

Alas the topbar area is not a part of the screen areas collection, nor have I found a way to reference it from windows or workspaces. There appears to be one instance of the topbar per main window opened.

Would prefer not to go down the slippery slope of patching the UI code directly. I build from source often and overwrite

This "orrible ack" adds a draw method to the topbar header that uses the driver namespace to store a reference to the area, toggle it, then remove the draw method.

import bpy
from bpy.app import driver_namespace as dns

def dummy_draw(self, context):
    dns["tba"] = context.area


count = 100
while not dns.get("tba") and count:
    count -= 1

#dns["tba"].show_menus = False # OFF
dns["tba"].show_menus = not dns["tba"].show_menus # TOGGLE
  • 1
    $\begingroup$ Add context.area.show_menus = False at line 209 in scripts\startup\bl_ui\space_topbar.py. Or remove the first part of the if-else block completely, if you don't plan on opening that meun again. $\endgroup$
    – Leander
    Commented May 1, 2020 at 14:04
  • $\begingroup$ @Leander cheers, using show_menus is much better than the op. Would prefer not to patch the UI code as it is overwritten by nightly build. The issue is can the topbar area be referenced from outside its context. Its not shown in screen areas or window or workspace AFAICT. Edited question. $\endgroup$
    – batFINGER
    Commented May 2, 2020 at 15:32


You must log in to answer this question.

Browse other questions tagged .