keeping a UIlayout box a specific width percentage

So I have searched hi and low for this on Google and here at BlenderArtist with no success. My plan is to have 2 columns in one row. The first column holding a box layout, and in the second column, I want an operator button. I would also like for the box layout take up 80 percent of the total width. Does anyone here know how to do this? I tried playing with the scale_x attribute but that did not seem to change anything.

try this:


import bpy

def drawtest(self,context):
    split = self.layout.split(percentage=0.8)
    col1,col2 = (split.column(),split.column())
    col1.label('col1')
    col1.label('col1')
    col1.label('col1')
    col1.label('col1')
    col2.operator('object.editmode_toggle')
bpy.types.VIEW3D_PT_tools_objectmode.append(drawtest)

Mocked this up last night forgot to post… pretty similar to dusties.



import bpy


class HelloWorldPanel(bpy.types.Panel):
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = "PROPERTIES"
    bl_region_type = "WINDOW"
    bl_context = "object"

    def draw(self, context):
        layout = self.layout

        obj = context.object
        row = layout.row()
        split = row.split(percentage=0.8,align=True)
        box = split.box()
        box.label(text="80")
        split.operator("wm.console_toggle")
        
        
        row = layout.row()
        row.label(text="Hello world!", icon='WORLD_DATA')

        row = layout.row()
        row.label(text="Active object is: " + obj.name)
        row = layout.row()
        row.prop(obj, "name")


def register():
    bpy.utils.register_class(HelloWorldPanel)


def unregister():
    bpy.utils.unregister_class(HelloWorldPanel)


if __name__ == "__main__":
    register()

thank you both. Also I found template_list, which better suits my needs. This works out since I am trying to create a folder collection. The folder collection will then allow my other script to search the given folders the user specifies.