ipywidgets icon indicating copy to clipboard operation
ipywidgets copied to clipboard

Simple representation, str method for Layout

Open marscher opened this issue 1 year ago • 0 comments

Problem

In order to easily inspect the a Layout instance of a widget, it'd be very useful to have a representation which displays all attributes. This way one can better understand the current layout.

Proposed Solution

A simple method which collects all attributes and formats them to a string:

def __str__(self):
    attributes = []
    for key, value in self.__dict__.items():
        if not key.startswith('_'):
            attributes.append(f"{key}={value}")
    return f"Layout({', '.join(attributes)})"

marscher avatar Apr 17 '24 09:04 marscher