When executing modal operators such as rotation, translation, or scale, text with the current values of the mesh parameters being changed is displayed in the header of the current area. If necessary, we can display any required text in the area header.
In order to display text in the area header, we need to call the “header_text_set” method of the required area, passing it a text string in the parameters.
If we just type in the Python console window:
1 |
bpy.context.area.header_text_set('Sample Text') |
The console header will be replaced with the “Sample Text” text.
If we need to display text in the header of a separate area, first we get a pointer to the desired area, for example, a 3D viewport:
1 |
viewport_area = next(area for area in bpy.context.screen.areas if area.type == 'VIEW_3D') |
and next we call the “header_text_set” method on it:
1 |
viewport_area.header_text_set('Hello World !') |
As a result, the “Hello World !” text will be displayed in the 3D viewport header.
To remove the text from the area header and return the menu back, we need to call the same “header_text_set” method with the None parameter:
1 |
viewport_area.header_text_set(None) |