0
$\begingroup$

I'm trying to find the proper way of positioning labels/buttons in the center of the Sequencer's Tool Settings bar.

I have a code that can easily add buttons/labels to the bar, but I can't figure out how to position them in the center, kind of like the dropdown with the shuffle option in the header(marked with the blue line in the attached picture). What would be the proper way of setting it up in the code?

Thank you so much!

enter image description here

import bpy
    
def draw_buttons(self, context):
    
    original_SEQUENCER_HT_tool_header_draw_tool_settings(self, context)

    row = self.layout.row()

    row.label(text = "BUTTON 1")

    row.label(text = "BUTTON 2")
        
          
original_SEQUENCER_HT_tool_header_draw_tool_settings = bpy.types.SEQUENCER_HT_tool_header.draw_tool_settings

def register():
    bpy.types.SEQUENCER_HT_tool_header.draw_tool_settings = draw_buttons

def unregister():
    bpy.types.SEQUENCER_HT_tool_header.draw_tool_settings = original_SEQUENCER_HT_tool_header_draw_tool_settings

if __name__ == "__main__":
    register()
$\endgroup$
2
  • $\begingroup$ i tried out your code....but there are no buttons at all...? $\endgroup$
    – Chris
    Commented Nov 10, 2022 at 9:23
  • $\begingroup$ When you check View > Tool Settings, you get the Tool header and the buttons. $\endgroup$ Commented Nov 10, 2022 at 10:31

1 Answer 1

1
$\begingroup$

The easiest way I found, is to add 3 columns to the row (left and right column are empty) and set a horizontal spacer between the columns.

import bpy
    
def draw_buttons(self, context):
    
    original_SEQUENCER_HT_tool_header_draw_tool_settings(self, context)

    # Add 3 columns in the row, with horizontal empty space between them
    layout = self.layout

    # Empty column on the left
    row = layout.row()
    layout.separator_spacer()

    # Column in the center
    row = layout.row()
    row.label(text = "BUTTON 1")
    row.label(text = "BUTTON 2")
    layout.separator_spacer()

    # Empty column on the right
    row = layout.row()
        
          
original_SEQUENCER_HT_tool_header_draw_tool_settings = bpy.types.SEQUENCER_HT_tool_header.draw_tool_settings

def register():
    bpy.types.SEQUENCER_HT_tool_header.draw_tool_settings = draw_buttons

def unregister():
    bpy.types.SEQUENCER_HT_tool_header.draw_tool_settings = original_SEQUENCER_HT_tool_header_draw_tool_settings

if __name__ == "__main__":
    register()
$\endgroup$
1
  • $\begingroup$ That is fantastic. Works great! Thank you so much!!! $\endgroup$ Commented Nov 10, 2022 at 18:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .