Open gabrielfougeron opened 1 month ago
For some reason, it seems that manually adding a home.flush_content()
before server.start()
solves the problem.
I think this is a bug. Can you confirm ?
Could you explain what is your intent in doing that?
def create_table():
row = vuetify.VRow(style="height: 100%")
with row:
with vuetify.VCol() as col:
row.col = col
return row
# Home route
home = RouterViewLayout(server, "/")
with home:
with vuetify.VCard():
vuetify.VCardTitle("This is home")
home.table = create_table()
I don't understand what you try to do when you assign home.table
, row.col
as well as the hierarchy you aim to build?
Also at the exit of any with
, that is when the flush_content is called. So if you properly define your hierarchy, you should be fine on the first go.
Are you trying to do the following?
with RouterViewLayout(server, "/"):
with vuetify.VCard():
vuetify.VCardTitle("This is home")
with vuetify.VRow(style="height: 100%"):
vuetify.VCol()
Thanks @jourdain for your response.
Also at the exit of any with, that is when the flush_content is called. So if you properly define your hierarchy, you should be fine on the first go.
Indeed, flush_content
is called in the __exit__
method of AbstractLayout
. It is AFAIK not called in the exit method of anything deriving from AbstractElement
. I think my problem stemmed from not understanding the distinction between those two.
If the tutorial made a distinction between those two notions (key to what you call "properly define your hierarchy"), I probably would have had an easier time.
You are correct, only the layout will flush itself at the exit of its with.
So to summarize:
The
with
notation of a widget ensure that every created widget within the context gets added as a child to the element in context. While for the layout, on top of the previously defined behavior, theflush_content
method will be called on exit.
If you see a good spot to add the text above, feel free to add a PR or suggest a location for it.
Hi,
I'm a trame beginner, and I cannot tell whether the results I'm getting are expected or if there is a bug. I've modified the example at https://github.com/Kitware/trame-router/blob/master/examples/vue2/basic.py to show what I mean:
I added three
html.Div
s in the example (last lines). Only two of them show up in the UI, and I cannot make sense of why.Could you please help me understand what is happening?
Cheers,
Gabriel Fougeron