Replies: 4 comments 3 replies
-
Why do you have to have callables on each page? |
Beta Was this translation helpful? Give feedback.
-
That' exactly, why I am asking :-) I need all pages to update, when the data is updated. And I think I did not fully understand the 'state' yet. |
Beta Was this translation helpful? Give feedback.
-
I am working on a trading-bot - my data are my transaction history, signals from tradingview and account informations from the exchange. Your little example gives me the idea, that I should have all relevant clallback-funktionality on the main() app level. That may solve all my issues. given the following structure: with tgb.Page() as my_page:
tgb.part(page="{my_url}")
tgb.table("{my_df}", id='my_page_table', rebuild=True) and in the main-app: def on_action(state, id, payload):
if id == 'my_page_table':
state['my_page'].my_url = some_function(payload)
navigate(state, 'My_Page')
pages = {'My_Page': my_page}
Gui(pages=pages).run() If I click on a line in that table, the url is updated according to that line. But I need to reload the page, after I changed the url - correct? |
Beta Was this translation helpful? Give feedback.
-
Yes, the part() only got updated after reloading the page. I changed the organization of the app. Now im am struggling with the on_action() callback. Having the on_action defined in main and no 'on_action = on_action' attribute in the tgb.table(), does not invoke the callable, when I click somewhere in the table. |
Beta Was this translation helpful? Give feedback.
-
I started to move an app from Streamlit to Tapir, because of the limitations with regard to real-time data.
I implemented my app with the help of this example wich is working basically.
Unfortunately I did not manage to invoke the data-receiving callable if the page was defined as a class.
My question:
I have multiple data-sources, running in different threads, invoked at main() level of the app.
What is the best practice for the data flow?
My first attempt was, to define the data in every sub-page and have a data-receiving callable in every sub-page. in that scenario I did not manage to exchange data between the pages, for example select one row in a df, and show a different page with the details of that data.
Next step was to define the data on the main() level, now the data exchange between pages works, but the callables on each page are trying to update the same data, wich gives me errors and warnings.
I appreciate any hints.
Beta Was this translation helpful? Give feedback.
All reactions