Access name of object that we use in the ide

Hi @DavidAtkins,

I don’t know how you accessed that particular piece of internal component state, but would strongly advise against relying on it, as it can and will change underneath you without warning. Generally speaking, accessing the name of a component isn’t something you should be able to do at runtime. The effect of creating a button called button_1 in the designer should be the same as the Python code:

    def __init__(self, **properties):
        # ...
        self.button_1 = Button(text="Click me!")

That is to say, the name itself is not accessible on the Button object; it’s an attribute on the form that points to that object. If you want to identify the button so that others can access information about it, you can attach information to its .tag property (for access from Python), or to its JS DOM object (for access from the browser)

A better way to identify components for testing frameworks is to set attributes or CSS classes on components’ DOM nodes, using the Python<>JS bridge. Here’s a writeup of doing that with Playwright:

3 Likes