New Release Hydralit: Multi-page apps even nicer

Hi, thanks for the example. I ran some tests with your code sample this morning, and with a variant with a complex menu added. I can confirm that:

  1. Menus always work correctly, whether flat or complex
  2. The buttons on the home page work correctly with flat menus
  3. The duplication occurs when using the button on the Home page when the menu set is complex.

In case 3 I was able to see a streamlit exception in the “loading_app” module by setting a breakpoint and stepping through with the debugger.

(Pdb) n
streamlit.script_runner.RerunException: RerunData(query_string=None, widget_states=None)
c:\apps\anaconda3\envs\dplogging\lib\site-packages\hydralit\loading_app.py(11)run()
→ app_target.run()
(Pdb) s
c:\apps\anaconda3\envs\dplogging\lib\site-packages\hydralit\loading_app.py(11)run()
→ app_target.run()

It looks like the script gets run twice on the button click, the first time the exception gets thrown. In normal running it appears the exception gets swallowed up somewhere and isn’t reported. Buttons often have weird side effects especially when used in combination with reruns.

For me the workaround is not to use buttons with complex menus, I don’t really need them. But thank you anyway, after stepping through this code I can see it is a really well designed and executed approach.

2 Likes

I really appreciate your analysis, this is very helpful. After your initial question, i ran a different round of tests and did find the bug you discovered with the complex nav, I will push a new release shortly that fixes that issue. The bug is actually in a branch condition that most people (including myself) never hit whereby there is no Login app with a complex nav. Thank you for taking the time to help investigate, your analysis will definitely be put to use, ultimately the bug comes from 1 line of code that should have been removed when i integrated the new nav bar, thanks again, will post when the new release is available.

2 Likes

Hydralit 1.0.9

A new version of Hydralit has been released with a number of performance improvements and bug fixes. Please also see the note below regarding the use of internal links.

A showcase live demo, including the fun Loader Playground app demonstrating the 20+ animated loaders now available within the Hydralit Components package has been updated with all the new features.

After alot of work on this package and a major release of Hydralit Components, this will be my last release for a while as there are plenty of opinions available within this community on how best to do multiple component Streamlit application.

I’m not interested in competing with dogmatic comments and gang-up style responses from a select few here, therefore a big thank you to everyone who has contributed, enjoyed and gained something from Hydralit and related projects and I wish you all the best.

I will continue to maintain the packages and if issues are found, I will be monitoring the issue tracker on the repos, I just won’t be pushing new features, functions, nice to haves, query parameters or security features and integrations further at this time.

Latest features

  • Can set auto login with guest account when using a secure app
  • Support for a non-secure app in a secure app (like a signup app)
  • Full integration with the Hydralit Navbar that now supports complex nav!
  • some bug fixes where app to app redirect was inconsistent
  • Banners
  • Compression behind download button
  • Hydralit Navbar
  • Can turn off the navbar animation now! (must be using Hydralit_components >=1.0.4)

NOTE

Due to the Streamlit execution model, the ability to use internal nav links from a child app is one-shot when using the navbar. This means that the internal link will redirect to the child, however if a script rerun request is made within the child app (changing the value of a widget for example), the nav will bounce back to the calling app. You can disable the navbar and the Streamlit core components nav menu will appear and the internal links will work as expected.

2 Likes

Thanks @Probability for such a potential package, it is really impressive !

Cheers,
Avra

A quick fix update for those that are in a hurry when wanting multi-page apps with Hydralit.

Now you can just wrap your functions with a decorator and get all the goodness of state management, auto generated navbar and so much more.

import hydralit as hy

app = hy.HydraApp(title='Simple Multi-Page App')

@app.addapp()
def my_home():
 hy.info('Hello from app1')

@app.addapp()
def app2():
 hy.info('Hello from app 2')


#Run the whole lot, we get navbar, state management and app isolation, all with this tiny amount of work.
app.run()

If you want to put alittle bit of kick on them with labels and icons, you can do it directly from the decorator. You don’t even need to import Streamlit, as it’s there for you already, one import to create all the apps and have access to all the Streamlit functionality.

#when we import hydralit, we automatically get all of Streamlit
import hydralit as hy

app = hy.HydraApp(title='Simple Multi-Page App')

@app.addapp(is_home=True)
def my_home():
 hy.info('Hello from Home!')

@app.addapp()
def app2():
 hy.info('Hello from app 2')

@app.addapp(title='The Best', icon="🥰")
def app3():
 hy.info('Hello from app 3, A.K.A, The Best 🥰')

#Run the whole lot, we get navbar, state management and app isolation, all with this tiny amount of work.
app.run()

Very nice work. However it would be good if there is a way to maintain the state of objects on individual pages.

@steeley Does this format solve your issues: Session State Variables are re-initialized to initial state going through pages - #6 by ryanlampkin

thanks - looks like that is a solution for now.

Hi my friend i have problem that i try to publicate my app in streamcloud that I use hydralit you can help me please?

Hey, just DM me and I’ll be happy to help, please let me know the trouble you’re having and I’m sure we can work it out together.

Hi, may I know how to DM you? Currently I faced a problem. I got few apps which can directed at the sidebar, now I want to link the sidebar and nav bar (using hydralit_components) which when I click on the nav bar, then it can directly me to the different app (so called multi pages), may I know how to do it? and also is it possible to applied using hydralit_components?

My navbar menu works well with full screen screen.

But change the size of the screen, the menu is compressed. Is it possible to disable compression?

1 Like

Hello! This looks like an absolutely fantastic app.

@Probability In your example, the login tab does not disappear upon login. Is there a way to keep it out of the navbar is the user is authenticated?

want to know that too!