Unregister a certain class

Hi, I tried to unregister a Part of the Texteditor

bpy.utils.unregister_class(TEXT_HT_header)

however, the console says:

NameError: name 'TEXT_HT_header' is not defined

How does this work?

AFAIK you can only register and unregister custom classes that you create… at the least, you’d need to register TEXT_HT_header before you could unregister it, but I don’t think that’ll work either

I’m assuming you didn’t import the class before attempting to reference it? Obviously that wouldn’t work because the class isn’t known in the scope.

You’ll need to import to get a reference from bpy.types import TEXT_HT_header, or use the full path relative to bpy.

All that said, you really shouldn’t be unregistering anything that you didn’t personally register in the first place.

1 Like

Ok, that kinda worked.

However, not as expected.

My Goal is it to remove this part of the Texteditors header…

When I unregister:
TEXT_HT_header

The entire Header disapears.

So, is ther a way to remove a certain layout Element?

Don’t remove from the default layout, only add to it. Everything in Blender’s UI is tied together, and most it goes much deeper than you can reach with the Python API. It might be possible to remove a default UI element, but it’s such bad practice with so much potential for disaster, that I’m not giving you any pointers in that direction. Why do you want to do this? What is your end goal? I’m thinking there’s probably a better way to accomplish your end goal

Yeah, well… you know. I just want to try it. If only to understand this better.
There is no need to protect me here.

So if you know where you could point me, please do.