# Removing Tabs from Tool Shelf (“T” key)

I'm trying to remove unwanted tabs in the left-hand toolshelf, such as "Grease Pencil" and others I never use. I saw an answer here from 2014 that suggested you edit the "space_view3d_toolbar.py" file in C:\Program Files\Blender Foundation\Blender\2.xx\scripts\startup\bl_ui, and comment out the class(es) that pertain to the tab you want to remove using """ at the start and end of the class.

However, I tried that for the Physics and Relations tabs, and it also removes a bunch of other tabs as well as the top menu. Also, this file doesn't seem to include the "Grease Pencil" or "Layers" tab info. I've done significant C# programming, so I doubt I messed up the commenting...

I'm wondering if something has changed in recent years. Is there a different file, or maybe I'm missing an easier tweak or add-on somewhere?

Thanks !!

Unregister the classes.

Rather than mess with the UI code, you can unregister the classes. When a class is registered it is added to bpy.types Using autocomplete in python console, dir(bpy.types) or looking at bl_ui.space_view3d_toolbar we can find the classes we wish to unregister.

Let's take the grease pencil tool bar panels as an example. The naming convention shows the panels we wish to remove start with VIEW3D_PT_tools_grease_pencil Similarly for animation.

Test script to remove grease pencil and animation 3d view toolbar.

import bpy
from bpy.utils import unregister_class

gpclasses = [c for c in dir(bpy.types)
if c.startswith("VIEW3D_PT_tools_grease_pencil")
or c.startswith("VIEW3D_PT_tools_animation")]

for c in gpclasses:
cls = getattr(bpy.types, c)
unregister_class(cls)


Change above script to suit.

Hit F8 to reinstate the panels.

• Excellent I'll give that a shot. And your solution even opens up the option of adding a "Tab Cleanup" function to the custom Tool tab I already have. It can remove or add tabs as needed. Sweet. – ebergerly Dec 30 '17 at 12:04
• Dude, that's excellent !!! I now have a button on the custom Tool tab I developed that unregisters selected tabs. It works great. Thanks much. – ebergerly Dec 30 '17 at 12:59
• By the way, it kinda surprises me that it works in real time. As soon as you click the button to run the unregister code you posted, it erases the tab. – ebergerly Dec 30 '17 at 13:04

I'm not really posting an answer, I just couldn't get my code to post in the comments.

For any other noobs like me out there who might want to know how to make a custom button to remove selected tabs using batFINGER's excellent code idea, here's what I came up with. It seems to work, and instantly deletes the tabs when you press the button. I merely packaged his code into a class (and just like you would with any custom button you also have to register the class and add it to the buttons on the tool shelf):

class RemoveTab(bpy.types.Operator):
"""This removes Grease Pencil, Relations, & Animation tabs"""
bl_idname = "myops.removetab"
bl_label = "Remove Tabs"

def execute(self, context):
gpclasses = [c for c in dir(bpy.types)
if c.startswith("VIEW3D_PT_tools_grease_pencil")
or c.startswith("VIEW3D_PT_tools_animation")
or c.startswith("VIEW3D_PT_tools_relations")]

for c in gpclasses:
cls = getattr(bpy.types, c)
unregister_class(cls)

return {'FINISHED'}


Thanks again batFINGER. I've been wanting to tackle this forever.

• Yeah, that's much nicer. And thanks much for the F8 trick to re-instate. That makes it so much nicer. I tweaked my answer to update per your idea. It works great. – ebergerly Dec 30 '17 at 14:48