0
$\begingroup$

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):
    #self.layout.label(text="Foo")
    dns["tba"] = context.area

bpy.types.TOPBAR_HT_upper_bar.prepend(dummy_draw)


while not dns.get("tba"):
    continue

dns["tba"].show_menus = False
bpy.types.TOPBAR_HT_upper_bar.remove(dummy_draw)
$\endgroup$
  • $\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 May 1 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 May 2 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.