-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add workaround demo for shinyswatch theme picker error
- Loading branch information
1 parent
513b057
commit 2640cff
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from shiny import App, ui, Inputs, Outputs, Session, reactive, render | ||
import shinyswatch | ||
|
||
app_ui = ui.page_auto( | ||
ui.output_ui("main_page"), | ||
ui.input_action_button("change_nav", "Change Nav"), | ||
theme=shinyswatch.theme.darkly, | ||
) | ||
|
||
|
||
def server(input: Inputs, output: Outputs, session: Session): | ||
nav_state = reactive.value(1) | ||
|
||
@reactive.calc | ||
def nav_items(): | ||
return [ | ||
ui.nav_panel(f"Page{i}", ui.markdown(f"# Page{i}")) | ||
for i in range(nav_state.get()) | ||
] | ||
|
||
@render.ui | ||
def main_page(): | ||
shinyswatch.theme_picker_server() | ||
return ui.navset_pill_list( | ||
*nav_items(), ui.nav_control(shinyswatch.theme_picker_ui()) | ||
) | ||
|
||
@reactive.effect | ||
@reactive.event(input.change_nav) | ||
def change_state(): | ||
nav_state.set(1 if nav_state.get() == 2 else 2) | ||
|
||
|
||
app = App(app_ui, server) |