widgetti / solara

A Pure Python, React-style Framework for Scaling Your Jupyter and Web Apps
https://solara.dev
MIT License
1.89k stars 138 forks source link

Default app layout #755

Closed JovanVeljanoski closed 1 month ago

JovanVeljanoski commented 1 month ago

According to the docs, we can specify a default app layout by creating a Layout object in an __init__.py file, in the same directory as the main file of the solara app.

Maybe I am doing something wrong, but this file does not seem to be picked up. Here is a pycafe example

The example also shows a way that I figured one can pass a custom Layout that works.

Do you think this is a bug, or have I wrongly understood or implemented the documentation.

Thank you.

P.S.: There is also some funny rendering bug of the test app, but I assume that is more of a pycafe thing rather than a solara thing, since it renders correctly locally - so can be ignored.

maartenbreddels commented 1 month ago

That is only the case for a package, so if you run foo.bar.mypages orso. In the case of pycafe, we run as solara run app.py (we might need to have a configuration for this, because i also would like to demo things like that).

What is your directory structure, and how do you start solara the the command line?

PS: I do recommend the explicit way, i.e. the part below This works - uncomment to see, and we're gonna change the docs to recommend that. Too many people get confused about how the autorouting works (including us).

JovanVeljanoski commented 1 month ago

Thank! I was not sure what's the recommended approach - the way the docs are written now looks like the __init__.py manner is preferred.

Passing a layout to Route is perfectly fine.

I also have a package like structure, but not a package that is meant to be installable. The app is also run as solara run file.py. It works fine both locally, docker etc..

Thanks