scolling horizontally in panel?

Does anyone know of a layout that allows to scroll horizontally inside of a panel? I need to list a 5 column layout, and I really hate to put my data vertically or tell the user that my script runs best in 1 3D view port and stretch the UI panel.

maybe try this:

import bpy

ob = (ob for ob in bpy.context.scene.objects if ob.type == 'MESH').__next__()
for i in range(24):
    ob.data.materials.append(bpy.data.materials.new(""))

class MATERIAL_UL_matslots_example(bpy.types.UIList):
    # The draw_item function is called for each item of the collection that is visible in the list.
    #   data is the RNA object containing the collection,
    #   item is the current drawn item of the collection,
    #   icon is the "computed" icon for the item (as an integer, because some objects like materials or textures
    #   have custom icons ID, which are not available as enum items).
    #   active_data is the RNA object containing the active property for the collection (i.e. integer pointing to the
    #   active item of the collection).
    #   active_propname is the name of the active property (use 'getattr(active_data, active_propname)').
    #   index is index of the current item in the collection.
    #   flt_flag is the result of the filtering process for this item.
    #   Note: as index and flt_flag are optional arguments, you do not have to use/declare them here if you don't
    #         need them.
    def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
        ob = data
        slot = item
        ma = slot.material
        # draw_item must handle the three layout types... Usually 'DEFAULT' and 'COMPACT' can share the same code.
        if self.layout_type in {'DEFAULT', 'COMPACT'}:
            # You should always start your row layout by a label (icon + text), this will also make the row easily
            # selectable in the list!
            # We use icon_value of label, as our given icon is an integer value, not an enum ID.
            # Note "data" names should never be translated!
            layout.label(text=ma.name if ma else "", translate=False, icon_value=icon)
            # And now we can add other UI stuff...
            # Here, we add nodes info if this material uses (old!) shading nodes.
            if ma and not context.scene.render.use_shading_nodes:
                manode = ma.active_node_material
                if manode:
                    # The static method UILayout.icon returns the integer value of the icon ID "computed" for the given
                    # RNA object.
                    layout.label(text="Node %s" % manode.name, translate=False, icon_value=layout.icon(manode))
                elif ma.use_nodes:
                    layout.label(text="Node <none>", translate=False)
                else:
                    layout.label(text="")
        # 'GRID' layout type should be as compact as possible (typically a single icon!).
        elif self.layout_type in {'GRID'}:
            layout.alignment = 'CENTER'
            layout.label(text="", icon_value=icon)


# And now we can use this list everywhere in Blender. Here is a small example panel.
class UIListPanelExample(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "UIList Panel"
    bl_idname = "OBJECT_PT_ui_list_example"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"

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

        obj = context.object
        
        cols = max(1, context.area.width // 90)
        flow = layout.column_flow(columns=cols)
        for i in range(24):
            flow.operator("object.select_all", text=str(i))

        # template_list now takes two new args.
        # The first one is the identifier of the registered UIList to use (if you want only the default list,
        # with no custom draw code, use "UI_UL_list").
        #layout.template_list("MATERIAL_UL_matslots_example", "", obj, "material_slots", obj, "active_material_index")

        # The second one can usually be left as an empty string. It's an additional ID used to distinguish lists in case you
        # use the same list several times in a given area.
        layout.template_list("MATERIAL_UL_matslots_example", "compact", obj, "material_slots",
                             obj, "active_material_index", type='GRID')


def register():
    bpy.utils.register_class(MATERIAL_UL_matslots_example)
    bpy.utils.register_class(UIListPanelExample)


def unregister():
    bpy.utils.unregister_class(MATERIAL_UL_matslots_example)
    bpy.utils.unregister_class(UIListPanelExample)


if __name__ == "__main__":
    register()


Also check the Icons addon, it sort of scrolls sidewards :wink:

@CoDEmanX, Thanks for helping out. However, silly me, I should of mentioned that I am still using Blender 2.64, which means that I cannot create a UIList class. However, the UI of Blender 2.64 does have the template_list() as one of its UI members. Also, while looking at a few examples, I think this is used for scolling through a list up and down (vertically), not left and right (horizontally). Am I correct on that, or can it scroll lists in both directions, or is the “scroll both directions” a new added feature to the latest version of Blender? For which ever case it may be, just so that you know, I need my list to scroll horizontally. Also I am not sure if I should start a new topic or if this falls with in this category. Since I am speaking of UILayouts, I am having troubles building this 5 column layout. At first you might think this seems simple, for the fact that I could just simply use a flow_column layout. This is not the case, because I need the 2 end corners out of the 5 columns to be approx. 3 characters in width and the others can split the remaining width. So for instance, if the width of the panel is 100, I could say column1 = 10px, column2 = 40, column3 = 40, column5 = 10.

there’s in fact no native ui elements that allows for horizontal scrolling and can be created with python.

so you can see what i created:

CoDEmanX, oh wow!!!, so your saying that your script calculates how many columns will fit in the panel. I do not know why I have not updated Blender. I guess it is because I am so use to purchased software, which you spend hundreds of dollars, so you keep it and don’t upgrade until you realize the newest version is not compatible with old farten computer. Also it is a shame that Blender’s interface does not allow for horizontal scrolling. I was really hoping to scroll horizontally for grouping purposes.