Skip to content

feat(gui): allow dataclass to embed gui - #11

Merged
jourdain merged 1 commit into
mainfrom
add-gui
Jun 10, 2026
Merged

jourdain merged 1 commit into
mainfrom
add-gui

Conversation

@jourdain

@jourdain jourdain commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@jourdain
jourdain requested a review from Justineantoine June 9, 2026 18:31
def compute_definition(trame_dataclass_class):
client_only = getattr(trame_dataclass_class, "CLIENT_ONLY_NAMES", [])
template_fn = getattr(trame_dataclass_class, "template", None)
template_str = template_fn().html if template_fn else ""

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIXME ! => need to provide server for properly handle trigger registration when using several servers.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be able to make it brake by using the non default server...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried with a child server and indeed it does not work, it even breaks silently

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you share your example that break it? That way I can make sure I fix it.

@Justineantoine Justineantoine Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used this main in examples/gui/contacts_embeded.py:

def main():
    main_server = get_server()
    server = main_server.create_child_server(prefix="child_")
    app = AddressBookApp(server)
    app.server.start()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow that was a tricky one and was caused by several things.

  1. what I was talking about was related to the template (str) generation and making sure a server and ideally the proper one was getting used for registering trigger name. And it happen that in the context, because the main UI was generated before, the used server was getting cached and was getting assigned when the template was generated. I changed that to pass the server from the protocol that requested that template.
  2. What you ran into was about template replacement for variable name and there was 2 issues
    a. the variable extraction was not working because we were not using ? as a separator. Therefore selected?.[0] was not tokenized to selected.
    b. when the js_expression translation was happening the setdefault on selected was not happening and therefore no translation to child_selected were happening. So on exit of the with, I now flush properties to apply defaults on the state.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread examples/gui/dynamic_list.py
def compute_definition(trame_dataclass_class):
client_only = getattr(trame_dataclass_class, "CLIENT_ONLY_NAMES", [])
template_fn = getattr(trame_dataclass_class, "template", None)
template_str = template_fn().html if template_fn else ""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried with a child server and indeed it does not work, it even breaks silently

Comment thread examples/gui/contacts_embeded.py Outdated
@jourdain
jourdain merged commit 68a1b12 into main Jun 10, 2026
12 checks passed
@jourdain
jourdain deleted the add-gui branch June 10, 2026 21:11
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

Successfully merging this pull request may close these issues.

2 participants