Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple representation, str method for Layout #3906

Open
marscher opened this issue Apr 17, 2024 · 0 comments
Open

Simple representation, str method for Layout #3906

marscher opened this issue Apr 17, 2024 · 0 comments

Comments

@marscher
Copy link

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)})"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant